-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummary_sensors.yaml
109 lines (105 loc) · 5.59 KB
/
summary_sensors.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#### COMBINED MOTION/LOCK SENSORS #####################################################
#### Source: https://community.home-assistant.io/t/wildcard-entities-card/72969/3
#######################################################################################
template:
- sensor:
- name: Motion Summary
state: >
{%-for sensor in states.binary_sensor| selectattr('attributes.device_class','defined')|selectattr('attributes.device_class', 'eq', 'motion')|selectattr('state', 'eq', 'on')|rejectattr('name', 'match', 'Front 4K') |map(attribute="name")|list
if sensor-%}
{%-if loop.index > 0-%}
{{ sensor | replace('Motion Sensor ', '') | replace(' Motion', '')}}{%-if not loop.last -%}{%-if(loop.index+1==loop.length)%} & {%else%}, {%endif-%}{%-else%} motion{%endif-%}
{%-endif-%}
{%-else-%}
No motion
{%-endfor-%}
icon: >
{% if states.binary_sensor| selectattr('attributes.device_class','defined')|selectattr('attributes.device_class', 'eq', 'motion')|selectattr('state', 'eq', 'on')|map(attribute="name")|list|length %}
mdi:run-fast
{%-else-%}
mdi:motion-sensor-off
{%-endif-%}
# DOORS
- name: Door Summary
state: >
{%-for sensor in states.binary_sensor| selectattr('attributes.device_class','defined')|selectattr('attributes.device_class', 'search', 'door')|selectattr('state', 'eq', 'on') |map(attribute='name')|list
if sensor -%}
{%-if loop.index > 0-%}
{{sensor}}{%-if not loop.last -%}{%-if(loop.index+1==loop.length)%} & {%else%}, {%endif-%}{%-else%} open{%endif-%}
{%-endif-%}
{%-else-%}
All Closed
{%-endfor-%}
icon: >
{%- if states.binary_sensor| selectattr('attributes.device_class','defined')|selectattr('attributes.device_class', 'search', 'door')|selectattr('state', 'eq', 'on') |map(attribute='name')|list %}
mdi:door-open
{%-else-%}
mdi:door-closed
{%-endif-%}
attributes:
count: "{{states.binary_sensor| selectattr('attributes.device_class','defined')|selectattr('attributes.device_class', 'search', 'door')|selectattr('state', 'eq', 'on') |map(attribute='name')|list|length}}"
# LIGHTS
- name: Light Summary
state: >
{% for light in states.light |selectattr('state', 'eq', 'on')|rejectattr('entity_id', 'search', 'infra_red_lights_in_night_mode')|map(attribute='name')|list
if light -%}
{%-if loop.index > 0-%}
{{light}}{%-if not loop.last -%}{%-if(loop.index+1==loop.length)%} & {%else%}, {%endif-%}{%-else%} on{%endif-%}
{%-endif-%}
{%-else-%}
All off
{%-endfor-%}
icon: >
{%- if states.light |selectattr('state', 'eq', 'on')|rejectattr('entity_id', 'search', 'infra_red_lights_in_night_mode')|map(attribute='name')|list|length %}
mdi:lightbulb-on
{%-else-%}
mdi:lightbulb-off
{%-endif-%}
attributes:
count: "{{states.light |selectattr('state', 'eq', 'on')|rejectattr('entity_id', 'search', 'infra_red_lights_in_night_mode')|map(attribute='name')|list|length }}"
# CLIMATE
- name: Climate Summary
state: >
{%-for entity in states.climate |selectattr('state', 'ne', 'off')|selectattr('state', 'ne', 'unavailable')|map(attribute='name')|list
if entity -%}
{%-if loop.index > 0-%}
{{entity | replace('A/C', '')}}{%-if not loop.last -%}{%-if(loop.index+1==loop.length)%} & {%else%}, {%endif-%}{%-else%} on{%endif-%}
{%-endif-%}
{%-else-%}
All off
{%-endfor-%}
icon: >
{%-if states.climate |selectattr('state', 'ne', 'off')|selectattr('state', 'ne', 'unavailable')|map(attribute='name')|list|length-%}
mdi:air-conditioner
{%-else-%}
mdi:hvac-off
{%-endif-%}
attributes:
count: "{{states.climate |selectattr('state', 'ne', 'off')|selectattr('state', 'ne', 'unavailable')|map(attribute='name')|list|length}}"
#### LOW BATTERY SENSOR ###############################################################
#### Source: https://community.home-assistant.io/t/wildcard-entities-card/72969/3
#######################################################################################
- name: Low Battery Summary
state: >
{%-for state in states.sensor if(state.attributes.device_class=="battery" and state.state | int(0) <= 25)-%}
{%-if loop.last-%}
{%-if loop.index > 0-%}
{%-for state in states.sensor if(state.attributes.device_class=="battery" and state.state | int(0) <= 25)-%}
{{state.name | replace('Battery Level', '')| replace('battery', '')| replace('Battery', '')}}{%-if not loop.last -%}{%-if(loop.index+1==loop.length)%} & {%else%}, {%endif-%}{%-else%} low{%endif-%}
{%-endfor-%}
{%-endif-%}
{%-endif-%}
{%-else-%}
Everything is charged
{%-endfor-%}
icon: >
{%-for state in states.sensor
if(state.attributes.device_class=="battery" and state.state | int(0) <= 25)-%}
{%-if loop.last-%}
{%-if loop.index > 0-%}
mdi:battery-10
{%-endif-%}
{%-endif-%}
{%-else-%}
mdi:battery
{%-endfor-%}