-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbasement-bathroom-sensor.yaml
206 lines (188 loc) · 4.95 KB
/
basement-bathroom-sensor.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
substitutions:
device_id: basement-bathroom-sensor
device_name: Basement Bathroom Sensor
board: d1_mini
ip_address: !secret basement_bathroom_sensor_ip
api_key: !secret basement_bathroom_sensor_key
pwd: !secret basement_bathroom_sensor_pwd
packages:
device_base: !include ./packages/device_base_esp8266.yaml
esphome:
on_boot:
then:
- output.turn_on: motion_pwr
binary_sensor:
- platform: gpio
name: Basement Bathroom Door
id: door
device_class: door
pin:
number: D7
mode: INPUT_PULLUP
- platform: gpio
name: Basement Bathroom Motion
id: motion
device_class: motion
pin:
number: D0
mode: INPUT_PULLDOWN_16
- platform: template
id: motion_delay_3s
lambda: return id(motion).state;
filters:
- delayed_off: 3s
on_press:
then:
- if:
condition:
and:
- binary_sensor.is_off: light
- binary_sensor.is_off: shower_light
- binary_sensor.is_off: heat
then:
- if:
condition:
binary_sensor.is_on: day_night
then:
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: light.basement_bathroom_light
else:
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: light.basement_shower_light
- platform: template
id: motion_delay_30s
lambda: return id(motion).state;
filters:
- delayed_off: 30s
- platform: template
id: motion_delay_5m
lambda: return id(motion).state;
filters:
- delayed_off: 5min
on_release:
then:
- if:
condition:
binary_sensor.is_off: trigger_humidity
then:
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: fan.basement_bathroom_fan
- platform: template
id: motion_delay_20m
lambda: return id(motion).state;
filters:
- delayed_off: 20min
- platform: template
id: trigger_motion
lambda: |-
if (id(door).state) {
return id(motion_delay_30s).state;
}
else {
return id(motion_delay_20m).state;
}
filters:
- delayed_off: 3s
on_release:
then:
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: light.basement_bathroom_light
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: light.basement_shower_light
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: switch.basement_bathroom_heater
- platform: template
id: trigger_humidity
lambda: return (id(humidity).state - id(median_humidity).state) > 5;
filters:
- delayed_off: 5min
on_release:
then:
- if:
condition:
binary_sensor.is_off: trigger_motion
then:
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: fan.basement_bathroom_fan
- platform: homeassistant
id: day_night
entity_id: input_boolean.day_night
- platform: homeassistant
id: light
entity_id: light.basement_bathroom_light
- platform: homeassistant
id: shower_light
entity_id: light.basement_shower_light
- platform: homeassistant
id: heat
entity_id: switch.basement_bathroom_heater
i2c:
sda: D2
scl: D1
scan: true
output:
- platform: gpio
pin: D3
id: bme_gnd
- platform: gpio
pin: D5
id: motion_gnd
- platform: gpio
pin: D6
id: motion_pwr
- platform: gpio
pin: D8
id: door_gnd
sensor:
- platform: bme280_i2c
temperature:
id: temperature
name: "Basement Bathroom Temperature"
pressure:
id: pressure
name: "Basement Bathroom Pressure"
humidity:
id: humidity
name: "Basement Bathroom Humidity"
address: 0x76
update_interval: 15s
- platform: template
name: "Basement Bathroom Median Humidity"
id: median_humidity
unit_of_measurement: '%'
icon: mdi:water-percent
lambda: return id(humidity).state;
update_interval: 60s
on_raw_value:
then:
- if:
condition:
binary_sensor.is_on: trigger_humidity
then:
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: fan.basement_bathroom_fan
filters:
- median:
window_size: 360
send_every: 2
send_first_at: 2
status_led:
pin:
number: D4
inverted: true