-
Notifications
You must be signed in to change notification settings - Fork 0
/
ultimate-fan-project-Vpomme.yaml
227 lines (209 loc) · 4.77 KB
/
ultimate-fan-project-Vpomme.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
substitutions:
device_name: "fan-bedroom"
friendly_name: "fan bedroom"
short_name: "bedroom"
project_name: "athom.relay-x4"
project_version: "1.2"
esphome:
name: "${device_name}"
project:
name: "${project_name}"
version: "${project_version}"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "${device_name} hostspot"
password: !secret hostspot_password
captive_portal:
logger:
api:
web_server:
port: 80
ota:
preferences:
flash_write_interval: 12h
esp8266:
board: esp8285
restore_from_flash: true
button:
- platform: restart
id: restart_button
name: "${friendly_name} restart"
sensor:
- platform: wifi_signal
name: ${friendly_name} Wifi Signal Strength
update_interval: 60s
- platform: uptime
name: ${friendly_name} Uptime
disabled_by_default: true
update_interval: 60s
binary_sensor:
- platform: gpio
id: button1
filters:
- delayed_on_off: 100ms
pin:
number: 5
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- if:
condition:
and:
- lambda: "return id(fan_bedroom).speed == 1;"
- fan.is_on: fan_bedroom
then:
- fan.turn_off: fan_bedroom
else:
- fan.turn_on:
id: fan_bedroom
speed: 1
- platform: gpio
id: button2
filters:
- delayed_on_off: 100ms
pin:
number: 2
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- if:
condition:
and:
- lambda: "return id(fan_bedroom).speed == 2;"
- fan.is_on: fan_bedroom
then:
- fan.turn_off: fan_bedroom
else:
- fan.turn_on:
id: fan_bedroom
speed: 2
- platform: gpio
id: button3
filters:
- delayed_on_off: 100ms
pin:
number: 0
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- if:
condition:
and:
- lambda: "return id(fan_bedroom).speed == 3;"
- fan.is_on: fan_bedroom
then:
- fan.turn_off: fan_bedroom
else:
- fan.turn_on:
id: fan_bedroom
speed: 3
switch:
- platform: gpio
id: relay1
pin:
number: 16
mode: OUTPUT
inverted: true
interlock: &interlock_group [relay1, relay2, relay3]
interlock_wait_time: 250ms
on_turn_on:
- number.set:
id: speedo
value: 1
- platform: gpio
id: relay2
pin:
number: 14
mode: OUTPUT
inverted: true
interlock: *interlock_group
interlock_wait_time: 250ms
on_turn_on:
- number.set:
id: speedo
value: 2
- platform: gpio
id: relay3
pin:
number: 12
mode: OUTPUT
inverted: true
interlock: *interlock_group
interlock_wait_time: 250ms
on_turn_on:
- number.set:
id: speedo
value: 3
light:
- platform: status_led
name: "${short_name} Status LED"
disabled_by_default: true
pin:
inverted: true
number: GPIO5
text_sensor:
- platform: wifi_info
ip_address:
name: "${friendly_name} IP Address"
disabled_by_default: true
fan:
- platform: speed
id: fan_bedroom
output: fan_o
name: "${short_name}"
speed_count: 3
restore_mode: RESTORE_DEFAULT_OFF
output:
- platform: template
id: fan_o
type: float
write_action:
- if:
condition:
lambda: return ((state == 0));
then:
- switch.turn_off: relay1
- switch.turn_off: relay2
- switch.turn_off: relay3
- if:
condition:
lambda: return ((state > 0) && (state < 0.4));
then:
- switch.turn_off: relay2
- switch.turn_off: relay3
- switch.turn_on: relay1
- if:
condition:
lambda: return ((state > 0.4) && (state < 0.7));
then:
- switch.turn_off: relay1
- switch.turn_on: relay2
- switch.turn_off: relay3
- if:
condition:
lambda: return ((state > 0.7));
then:
- switch.turn_off: relay1
- switch.turn_off: relay2
- switch.turn_on: relay3
number:
- platform: template
name: "${friendly_name} speed"
id: speedo
icon: mdi:fan
update_interval: never
optimistic: true
min_value: 1
max_value: 3
initial_value: 1
step: 1
set_action:
- lambda: !lambda |-
auto call = id(fan_bedroom).turn_on();
call.set_speed(x);
call.perform();