-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbedroomceilingfan.yaml
262 lines (235 loc) · 6.95 KB
/
bedroomceilingfan.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
substitutions:
device_name: bedroomceilingfan
device_displayname: IFAN04 Bedgroom
esphome:
name: $device_name
friendly_name: $device_displayname
esp8266:
board: esp8285
framework:
version: latest
early_pin_init: true
restore_from_flash: true
preferences:
flash_write_interval: 50min
logger:
baud_rate: 0
level: DEBUG
api:
encryption:
key: !secret esphome_api_pass
ota:
password: !secret esphome_ota_pass
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: yes
ap:
ssid: $device_name
password: $backup-wifi_password
captive_portal:
web_server:
port: 80
#mqtt:
# broker: 10.0.0.2
# username: livingroomfan
# password: !secret mqtt_password
status_led:
pin:
number: GPIO13
inverted: true
#i2c:
# sda: GPIO04
# scl: GPIO05
# frequency: 200kHz
remote_receiver:
pin: GPIO3
output:
- platform: gpio
id: light_relay
pin:
number: GPIO09
inverted: true
- platform: gpio
id: buzzer
pin:
number: GPIO10
inverted: true
- platform: gpio
id: fan_relay_1
pin: GPIO14
- platform: gpio
id: fan_relay_2
pin: GPIO12
- platform: gpio
id: fan_relay_3
pin: GPIO15
- platform: template
id: fan_relays
type: float
write_action:
- if: # Fan off
condition:
lambda: return (state < 0.3);
then:
- if:
condition:
and:
- switch.is_on: ${device_name}_buzzer
then:
- output.turn_on: buzzer
- delay: 300ms
- output.turn_off: buzzer
- output.turn_off: fan_relay_1
- output.turn_off: fan_relay_2
- output.turn_off: fan_relay_3
- if: # Fan low speed
condition:
lambda: return ((state >= 0.3) && (state < 0.6));
then:
- if:
condition:
and:
- switch.is_on: ${device_name}_buzzer
then:
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- output.turn_off: fan_relay_3
- output.turn_on: fan_relay_1
- output.turn_on: fan_relay_2
- delay: 5s
- output.turn_off: fan_relay_2
- if: # Fan mid speed
condition:
lambda: return ((state >= 0.6) && (state < 0.9));
then:
- if:
condition:
and:
- switch.is_on: ${device_name}_buzzer
then:
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- delay: 100ms
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- output.turn_off: fan_relay_3
- output.turn_on: fan_relay_1
- output.turn_on: fan_relay_2
- if: # Fan high speed
condition:
lambda: return (state >= 0.9);
then:
- if:
condition:
and:
- switch.is_on: ${device_name}_buzzer
then:
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- delay: 100ms
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- delay: 100ms
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- output.turn_off: fan_relay_2
- output.turn_off: fan_relay_3
- output.turn_on: fan_relay_1
- delay: 5s
- output.turn_on: fan_relay_3
- output.turn_off: fan_relay_1
light:
- platform: binary
name: 'Light'
id: ${device_name}_light
output: light_relay
fan:
- platform: speed
name: 'Fan'
id: ${device_name}_fan
output: fan_relays
speed_count: 3
switch:
- platform: template
name: 'Buzzer enabled'
id: ${device_name}_buzzer
entity_category: config
optimistic: True
restore_mode: RESTORE_DEFAULT_OFF
sensor:
- platform: wifi_signal
name: 'WiFi signal'
- platform: uptime
name: 'Uptime'
unit_of_measurement: s
binary_sensor:
- platform: gpio
name: "Button"
pin:
number: GPIO00
inverted: true
- platform: remote_receiver
name: "Buzzer"
id: remote_buzzer
internal: true
raw:
code: [-207, 104, -103, 104, -104, 103, -104, 207, -104, 103, -104, 103, -104, 104, -103, 104, -103, 104, -104, 107, -721, 105, -206, 207, -518, 105, -931, 104, -104, 103, -725, 104, -104, 103, -725, 104, -104, 103, -207, 104, -414]
on_release:
then:
- switch.toggle: ${device_name}_buzzer
- platform: remote_receiver
name: "Fan 0"
id: remote_0
raw:
code: [-207, 104, -103, 104, -104, 103, -104, 207, -104, 103, -104, 104, -103, 104, -104, 103, -104, 105, -102, 104, -725, 104, -311, 103, -518, 104, -933, 103, -104, 104, -725, 104, -932, 104, -207, 207, -519]
on_release:
then:
- fan.turn_off: ${device_name}_fan
internal: true
- platform: remote_receiver
id: remote_fan1
raw:
code: [-207, 104, -104, 103, -104, 104, -103, 207, -104, 104, -103, 104, -104, 103, -104, 104, -103, 104, -104, 103, -726, 103, -312, 103, -518, 104, -933, 103, -104, 104, -725, 104, -103, 104, -726, 103, -104, 311, -518]
on_release:
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 1
internal: true
- platform: remote_receiver
id: remote_fan2
raw:
code: [-208, 103, -104, 104, -103, 104, -103, 208, -103, 104, -104, 103, -104, 104, -103, 104, -104, 103, -104, 103, -726, 104, -310, 104, -518, 104, -933, 103, -104, 104, -725, 104, -207, 104, -622, 103, -416, 102, -415]
on_release:
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 2
internal: true
- platform: remote_receiver
id: remote_fan3
raw:
code: [-207, 104, -104, 103, -104, 104, -103, 208, -103, 104, -104, 103, -104, 104, -103, 104, -104, 103, -104, 103, -726, 104, -311, 104, -518, 103, -934, 103, -103, 104, -726, 103, -104, 207, -622, 104, -103, 104, -207, 104, -415]
on_release:
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 3
internal: true
- platform: remote_receiver
id: remote_light
raw:
code: [-207, 104, -103, 104, -104, 103, -104, 207, -104, 103, -104, 104, -103, 104, -103, 104, -104, 103, -104, 104, -725, 104, -311, 103, -518, 104, -933, 103, -104, 103, -726, 103, -311, 104, -518, 104, -207, 104, -103, 104, -414]
on_release:
then:
- light.toggle: ${device_name}_light
text_sensor:
- platform: version
name: 'ESPHome Version'