Just cleaned up the code thanks to @burnshomeautomation and @CCOSTAN

This commit is contained in:
Jeffrey Stone 2019-10-05 20:42:30 -04:00
parent 0dae10b22c
commit f4e36a424d
1 changed files with 14 additions and 76 deletions

View File

@ -77,97 +77,35 @@
sensor_count: sensor_count:
friendly_name: 'Number of Sensors' friendly_name: 'Number of Sensors'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['sensor'] -%} {{ states.sensor | list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
automation_count: automation_count:
friendly_name: 'Number of Automations' friendly_name: 'Number of Automations'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['automation'] -%} {{ states.automation| list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
script_count: script_count:
friendly_name: 'Number of Scripts' friendly_name: 'Number of Scripts'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['script'] -%} {{ states.script | list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
binary_sensor_count: binary_sensor_count:
friendly_name: 'Number of Binary Sensors' friendly_name: 'Number of Binary Sensors'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['binary_sensor'] -%} {{ states.binary_sensor | list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
tracker_count: tracker_count:
friendly_name: 'Number of Devices' friendly_name: 'Number of Devices'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['device_tracker'] -%} {{ states.device_tracker| list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
lights_count: lights_count:
friendly_name: 'Number of Lights' friendly_name: 'Number of Lights'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['light'] -%} {{ states.light | list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
protect_count:
friendly_name: 'Number of Smoke Detectors'
entity_id: []
value_template: >
{% if states('group.protects') == 'on' %}
{% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
{% if loop.last %}
{{ loop.index }}
{% endif %}
{%- endfor -%}
{% else %}
0
{% endif %}
camera_count: camera_count:
friendly_name: 'Number of online Cameras' friendly_name: 'Number of online Cameras'
entity_id: [] entity_id: []
value_template: > value_template: >-
{%- set domains = ['camera'] -%} {{ states.camera | list | count }}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}