neilimixamo / Home-Assistant-Quick-Look-Mobile

118 stars 6 forks source link

New install loads with error but no idea how to resolve #2

Closed jata1 closed 1 year ago

jata1 commented 1 year ago

Thanks for sharing this project. I am using it to learn more about HA.

Installed and I have the Quick Look Mobile dashboard in my side bar but this is what it looks like.

Not sure what to do...

Screenshot 2023-06-13 at 1 21 05 pm

neilimixamo commented 1 year ago

Hi jata1,

It seems that Home Assistant is having trouble accessing the template sensors files within entities/sensors/.

The most likely explanation is that the 'sensor:' integration in your configuration.yaml file already includes some other sensors and do not accept "!include_dir_list entities/sensors/".

In your case, you can simply add those templates directly into your "configuration.yaml" file replacing :

sensor: !include_dir_list entities/sensors/

by

sensor: 
  - platform: template
    sensors: 
      some_alarms_are_on:
        friendly_name: "Some Alarms Are On"
        value_template: >-
          {% set entity_ids = [
            'alarm_control_panel.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'triggered') or is_state(entity_id, 'pending') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

  - platform: template
    sensors:
      some_climates_are_on:
        friendly_name: "Some climates are on"
        value_template: >-
          {% set entity_ids = [
            'climate.your_entity',
            'climate.your_entity',
            'climate.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'heat') or is_state(entity_id, 'on') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

  - platform: template
    sensors:
      some_contact_sensors_are_on:
        friendly_name: "Some Contact Sensors Are On"
        value_template: >-
          {% set entity_ids = [
            'binary_sensor.your_entity', 
            'binary_sensor.your_entity',
            'binary_sensor.your_entity',
            'binary_sensor.your_entity',
            'binary_sensor.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'on') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

  - platform: template
    sensors:
      some_devices_are_on:
        friendly_name: "Some Devices Are On"
        value_template: >-
          {% set entity_ids = [
            'switch.your_entity',
            'switch.your_entity',
            'switch.your_entity',
            'switch.your_entity',
            'switch.your_entity',
            'vacuum.your_entity',
            'vacuum.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in 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' }}

  - platform: template
    sensors:
      some_fans_are_on:
        friendly_name: "Some fans are on"
        value_template: >-
          {% set entity_ids = [
            'fan.your_entity',
            'fan.your_entity',
            'fan.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'on') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

  - platform: template
    sensors:
      some_lights_are_on:
        friendly_name: "Some Lights Are On"
        value_template: >-
          {% set entity_ids = [
            'light.your_entity',
            'light.your_entity',
            'light.your_entity',
            'light.your_entity',
            'light.your_entity',
            'light.your_entity',
            'light.your_entity',
            'light.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'on') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

  - platform: template
    sensors:
      some_media_players_are_on:
        friendly_name: "Some Media Players Are On"
        value_template: >-
          {% set entity_ids = [
            'media_player.your_entity',
            'media_player.your_entity',
            'media_player.your_entity',
            'media_player.your_entity'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'playing') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

  - platform: template
    sensors:
      some_occupancy_sensors_are_on:
        friendly_name: "Some Occupancy Sensors Are On"
        value_template: >-
          {% set entity_ids = [
            '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'
            ] %}

          {% set count = namespace(value=0) %}

          {% for entity_id in entity_ids %}
            {% if is_state(entity_id, 'on') %}
              {% set count.value = count.value + 1 %}
            {% endif %}
          {% endfor %}

          {{ 'off' if count.value == 0 else 'on' }}

Then replace every "your_entity", add some more or delete those you don't need

Hope this resolves your issue. Don't hesitate to reach out if you encounter any further problems.

jata1 commented 1 year ago

Thanks @neilimixamo. That worked. Quite a lot still to do to get this all configured.