neilimixamo / Home-Assistant-Quick-Look-Mobile

127 stars 6 forks source link

Cant get header sensors to work. #25

Closed rampestamper closed 10 months ago

rampestamper commented 10 months ago

I cant get the header sensors to work. they keep saing unavailable.

here is my jinja code:

# v2.0.1

#### PART 1 ########################################################################################################################
#
# This file consists of two parts.
# Only first part requires a modification from you. 
# To prioritize simplicity and compatibility, I have chosen to individually list all the entities to be monitored in the Header.
# Replace every "your_entity" with your personal entities IDs
# The second part may be changed but is intended for advanced users who wish to create smart rules for entities inclusion or exclusion.
#
####################################################################################################################################

############################
#
# SECURITY MONITORING
#
############################

# ALARMS :
{% set alarm_entity_ids = [
  'alarm_control_panel.alarmo',
  'alarm_control_panel.home_alarm'
] %}

# DOORS & WINDOWS :
{% set contact_entity_ids = [
  'binary_sensor.btr_sens_dcs_contact', 
  'binary_sensor.hlw_sens_dcs_contact',
  'binary_sensor.mbr_sens_wcs_contact'
  #'binary_sensor.your_entity',
  #'binary_sensor.your_entity',
  #'binary_sensor.your_entity',
  #'binary_sensor.your_entity',
  #'binary_sensor.your_entity',
  #'binary_sensor.your_entity',
  #'binary_sensor.your_entity',
] %}

# PRESENCES:        
{% set occupancy_entity_ids = [
  'binary_sensor.mbr_sens_ms_occupancy',
  'binary_sensor.off_sens_ms_occupancy',
  'binary_sensor.bewegingssensor_badkamer_motion',
  'binary_sensor.bewegingssensor_toilet_iaszone',
  'binary_sensor.signify_netherlands_b_v_sml003_occupancy',
  'binary_sensor.mbr_sens_ps_presence',
  'binary_sensor.signify_netherlands_b_v_sml003_occupancy_2'
] %}

# LOCKS:        
{% set locks_entity_ids = [
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
  'lock.your_entity',
] %}

############################
#
# AIR MONITORING
#
############################

# CLIMATES :
{% set climate_entity_ids = [
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
  'climate.your_entity',
] %}

# FANS :
{% set fan_entity_ids = [
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
  'fan.your_entity',
] %}

############################
#
# LIGHT
#
############################

# LIGHTBULBS :
{% set light_entity_ids = [
  'light.hallway_lamp_double_left_light_3',
  'light.hallway_lamp_double_right_light',
  'light.hallway_lamp_single_light_2'
] %}

# COVERS :
{% set cover_entity_ids = [
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
  'cover.your_entity',
] %}

############################
#
# MEDIA PLAYERS MONITORING
#
############################

# AUDIO PLAYERS :
{% set audio_player_entity_ids = [
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
  'media_player.your_entity',
] %}

# VIDEO PLAYERS :
{% set video_player_entity_ids = [
  'media_player.your_entity',
  'media_player.your_entity',
] %}

############################
#
# EQUIPMENT MONITORING
#
############################

# DEVICES (SWITCHES, VACUUMS, SENSORS, etc) :
{% set device_entity_ids = [
  'vacuum.your_entity',
  'vacuum.your_entity',
  'vacuum.your_entity',
  'switch.your_entity',
  'switch.your_entity',
  'switch.your_entity',
  'switch.your_entity',
  'vacuum.your_entity',
  'switch.your_entity',
  'switch.your_entity',
  'switch.your_entity',
  'switch.your_entity',
  'switch.your_entity',
] %}

    |   |
    |   |
    |   |    
    |   |
    |   |
    |   |
   \     /
    \   /
     \ /

### PART 2 #########################################################################################################################
#
# MACROS :
# Don't change the following code unless you have experience with Jinja2 templating. 
# Any incorrect modifications may lead to unpredictable results.
#
####################################################################################################################################

{% macro some_alarms_are_on() %}
  {% set triggered_count = namespace(value=0) %}
  {% set armed_count = namespace(value=0) %}
  {% for entity_id in alarm_entity_ids %}
    {% if is_state(entity_id, 'triggered') or is_state(entity_id, 'pending') %}
      {% set triggered_count.value = triggered_count.value + 1 %}
    {% elif states(entity_id).startswith('armed') %}
      {% set armed_count.value = armed_count.value + 1 %}
    {% endif %}
  {% endfor %}
  {% if triggered_count.value > 0 %}
    {{ 'on' ~ ',' ~ triggered_count.value }}
  {% else %}
    {{ 'off' if armed_count.value == 0 else 'armed' ~ ',' ~ armed_count.value }}
  {% endif %}
{% endmacro %}

{% macro some_contact_sensors_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in contact_entity_ids %}
    {% if is_state(entity_id, 'on') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_occupancy_sensors_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in occupancy_entity_ids %}
    {% if is_state(entity_id, 'on') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_locks_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in locks_entity_ids %}
    {% if is_state(entity_id, 'unlocked') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_climates_are_on() %}
  {% set ns = namespace(result='', count=0) %}
  {% for entity in climate_entity_ids %}
    {% set entity_state = states(entity) %}
    {% if ns.result %}
      {% set ns.result = ns.result ~ ', ' ~ entity_state %}
    {% else %}
      {% set ns.result = entity_state %}
    {% endif %}
    {% if entity_state in ['heat', 'cool', 'fan', 'dry', 'auto'] %}
      {% set ns.count = ns.count + 1 %}
    {% endif %}
  {% endfor %} 
  {% set dominant_state = 'off' %}
  {% if 'heat' in ns.result %} 
    {% set dominant_state = 'heat' %}
  {% elif 'auto' in ns.result %} 
    {% set dominant_state = 'auto' %}
  {% elif 'cool' in ns.result or 'fan' in ns.result %} 
    {% set dominant_state = 'cool' %}
  {% elif 'dry' in ns.result %} 
    {% set dominant_state = 'dry' %}
  {% endif %}
  {{ dominant_state }}, {{ ns.count }}
{% endmacro %}

{% macro some_fans_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in fan_entity_ids %}
    {% if is_state(entity_id, 'on') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_lights_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in light_entity_ids %}
    {% if is_state(entity_id, 'On') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {% set state = 'off' if count.value == 0 else 'On' %}
  {{ state ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_covers_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in cover_entity_ids %}
    {% if is_state(entity_id, 'closed') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_audio_players_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in audio_player_entity_ids %}
    {% if is_state(entity_id, 'on') or is_state(entity_id, 'playing') or is_state(entity_id, 'buffering') or is_state(entity_id, 'paused') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_video_players_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in video_player_entity_ids %}
    {% if is_state(entity_id, 'on') or is_state(entity_id, 'playing') or is_state(entity_id, 'buffering') or is_state(entity_id, 'paused') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

{% macro some_devices_are_on() %}
  {% set count = namespace(value=0) %}
  {% for entity_id in device_entity_ids %}
    {% if is_state(entity_id, 'on') or is_state(entity_id, 'cleaning') %}
      {% set count.value = count.value + 1 %}
    {% endif %}
  {% endfor %}
  {{ 'off' if count.value == 0 else 'on' ~ ',' ~ count.value }}
{% endmacro %}

i havent changed the quick_look_mobile_sensors (v2.0.0).yaml file but i am running another sensors.yaml file in the same folder. (entities/sensors) and to get to these i am calling them from my configuration.yaml file like this: sensor: !include_dir_merge_list entities/sensors/

Somehow my excisiting sensors are working fine in the sensors.yaml file but all the sensors from the quick_look_mobile_sensors (v2.0.0).yaml keep showing unavailable.

does anybody know what i am doing wrong?