-
Notifications
You must be signed in to change notification settings - Fork 186
/
binary_sensors.yaml
executable file
·221 lines (194 loc) · 8.68 KB
/
binary_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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
#-
# _ _
# | |__ (_)_ __ __ _ _ __ _ _ ___ ___ _ __ ___ ___ _ __ ___
# | '_ \| | '_ \ / _` | '__| | | | / __|/ _ \ '_ \/ __|/ _ \| '__/ __|
# | |_) | | | | | (_| | | | |_| | \__ \ __/ | | \__ \ (_) | | \__ \
# |_.__/|_|_| |_|\__,_|_| \__, |___|___/\___|_| |_|___/\___/|_| |___/
# |___/_____|
#
#- from github.com/basnijholt/home-assistant-config
- platform: template
sensors:
someone_showering:
friendly_name: Someone is showering
value_template: >
{% set humidity = states("sensor.humidity_bathroom") | float(0) %}
{% set treshold = 1.05 * state_attr("sensor.humidity_bathroom_stats", "median") | float(0) %}
{% set derivative = states("sensor.humidity_bathroom_derivative") | float(0) %}
{{ humidity > treshold and derivative > 0.25 }}
motion_detected:
friendly_name: Any motion detected
value_template: >
{{ is_state("binary_sensor.activity_in_bathroom", "on")
or is_state("binary_sensor.activity_in_dinner_area", "on")
or is_state("binary_sensor.activity_in_living_room", "on")
or is_state("binary_sensor.activity_in_kitchen", "on")
or is_state("binary_sensor.activity_in_utility_room", "on")
or is_state("binary_sensor.activity_in_master_bedroom", "on")
or is_state("binary_sensor.activity_in_baby_room", "on")
or is_state("binary_sensor.activity_in_guest_room", "on") }}
motion_detected_in_last_hour:
friendly_name: Any motion detected in last hour
value_template: >
{{ is_state("binary_sensor.motion_detected", "on") }}
delay_off: "01:00:00"
someone_in_the_house_in_last_hour:
friendly_name: Someone in the house in the last hour
value_template: >
{{ is_state("binary_sensor.motion_detected_in_last_hour", "on")
or is_state("group.persons", "home") }}
activity_in_bathroom:
friendly_name: Activity in the bathroom
value_template: >
{{ is_state("binary_sensor.motion_sensor_bathroom", "on")
or is_state("binary_sensor.motion_sensor_toilet", "on")
or is_state("binary_sensor.someone_showering", "on") }}
delay_off: "00:03:00"
activity_in_dinner_area:
friendly_name: Activity in dinner area
value_template: >
{{ is_state("binary_sensor.motion_sensor_dinner_area_occupancy", "on") }}
delay_off: "00:05:00"
activity_in_living_room:
friendly_name: Activity in the living room
value_template: >
{{ is_state("binary_sensor.motion_sensor_fireplace_occupancy", "on")
or is_state("binary_sensor.motion_sensor_dinner_area_occupancy", "on")
or is_state("binary_sensor.motion_sensor_living_room_kallax_occupancy", "on")
or is_state("binary_sensor.motion_sensor_mid_room_occupancy", "on")
or is_state("media_player.tv", "on")
or is_state("media_player.living_room_xbox", "on") }}
delay_off: "00:30:00"
activity_in_kitchen:
friendly_name: Activity in the kitchen
value_template: >
{{ is_state("binary_sensor.motion_sensor_kitchen_occupancy", "on") }}
delay_off: "00:01:00"
activity_in_utility_room:
friendly_name: Activity in the utility room
value_template: >
{{ is_state("binary_sensor.motion_sensor_utility_room_occupancy", "on")
or is_state("binary_sensor.openclose_utility_room_door", "on") }}
delay_off: "00:01:00"
activity_in_hall:
friendly_name: Activity in the hall
value_template: >
{{ is_state("binary_sensor.motion_sensor_hall", "on")
or is_state("binary_sensor.openclose_front_door", "on") }}
delay_off: "00:01:00"
activity_in_master_bedroom:
friendly_name: Activity in the bedroom
value_template: >
{{ is_state("binary_sensor.motion_sensor_master_bedroom_occupancy", "on")
or is_state("binary_sensor.vibration", "on") }}
delay_off: "00:01:00"
activity_in_baby_room:
friendly_name: Activity in the baby room
value_template: >
{{ is_state("binary_sensor.motion_sensor_baby_room_occupancy", "on")
or is_state("binary_sensor.motion_sensor_baby_room_2_occupancy", "on") }}
delay_off: "00:01:00"
activity_in_guest_room:
friendly_name: Activity in the guest room
value_template: >
{{ is_state("binary_sensor.motion_sensor_guest_room_occupancy", "on")
or is_state("binary_sensor.using_macbook_in_guest_room", "on")
or is_state("binary_sensor.vibration", "on") }}
delay_off: "00:10:00"
activity_outside_front_door:
friendly_name: Activity outside front door
value_template: >
{{ is_state("binary_sensor.motion_sensor_outside_front_door_occupancy", "on")
or is_state("binary_sensor.openclose_front_door", "on") }}
delay_off: "00:01:00"
activity_outside_garage:
friendly_name: Activity outside garage
value_template: >
{{ is_state("binary_sensor.motion_sensor_outside_garage_occupancy", "on")
or is_state("binary_sensor.openclose_utility_room_door", "on") }}
delay_off: "00:01:00"
activity_outside_house:
friendly_name: Activity outside house
value_template: >
{{ is_state("binary_sensor.activity_outside_garage", "on")
or is_state("binary_sensor.activity_outside_front_door", "on") }}
delay_off: "00:01:00"
activity_outside_bedroom:
friendly_name: Activity outside the bedroom
value_template: >
{{ is_state("binary_sensor.activity_in_living_room", "on")
or is_state("binary_sensor.activity_in_utility_room", "on")
or is_state("binary_sensor.activity_in_master_bedroom", "on")
or is_state("binary_sensor.activity_in_baby_room", "on")
or is_state("binary_sensor.activity_in_guest_room", "on") }}
delay_off: "00:01:00"
door_to_outside_open:
friendly_name: Door to outside open
value_template: >
{{ is_state("binary_sensor.openclose_utility_room_door", "on")
or is_state("binary_sensor.openclose_front_door", "on") }}
washing_machine:
friendly_name: Washing machine
value_template: >
{{ states("sensor.washing_machine_power") | float(0) > 3 }}
delay_off: "00:05:00"
icon_template: >
{% if is_state("binary_sensor.washing_machine", "on") %}
mdi:washing-machine
{% else %}
mdi:washing-machine-off
{% endif %}
dishwasher:
friendly_name: Dishwasher
value_template: >
{{ states("sensor.dishwasher_watts") | float(0) > 3 }}
delay_off: "00:03:00"
icon_template: >
{% if is_state("binary_sensor.dishwasher", "on") %}
mdi:dishwasher
{% else %}
mdi:dishwasher-off
{% endif %}
worked_enough_today:
friendly_name: Worked enough today
value_template: >
{{ states("sensor.time_at_work_today") | float(0) > 8 }}
icon_template: mdi:briefcase
any_light_on:
friendly_name: Any light is on
value_template: >
{% set automatic_lights_on = is_state("light.automatic_lights", "on") %}
{% set bedroom_lights_on = is_state("light.bedroom_lights", "on") %}
{% set living_room_lights_on = is_state("light.living_room_lights", "on") %}
{{ automatic_lights_on or bedroom_lights_on or living_room_lights_on }}
anything_on:
friendly_name: Anything is on
value_template: >
{% set light_on = is_state("binary_sensor.any_light_on", "on") %}
{% set tv_on = is_state("media_player.tv", "on") %}
{% set kef_on = is_state("media_player.kef_ls50", "on") %}
{% set kef_lsx_on = is_state("media_player.kef_lsx", "on") %}
{{ light_on or tv_on or kef_on or kef_lsx_on }}
vacuum_day:
# XXX: was '("Mon", "Wed", "Sun")' pre-corona because now we're mostly at home
friendly_name: Vacuum day today
value_template: >
{{ as_timestamp(now()) | timestamp_custom("%a") in ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") }}
no_one_home:
friendly_name: No one is home
value_template: >
{{ not is_state("person.bas", "home")
and not is_state("person.marcella", "home") }}
using_macbook_in_guest_room:
friendly_name: Activity in the guest room
value_template: >
{{ is_state("sensor.basnijholt_macbook_primary_display_name", "DELL U4021QW")
and is_state("binary_sensor.basnijholt_macbook_active", "on") }}
delay_off: "00:01:00"
- platform: trend
sensors:
humidity_bathroom_trend:
entity_id: sensor.humidity_bathroom
sample_duration: 300
max_samples: 3