-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathultimate-fan-project-V3.yaml
194 lines (179 loc) · 4.25 KB
/
ultimate-fan-project-V3.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
substitutions:
name: kitchen
esphome:
name: fan-${name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
api:
ota:
platform: esphome
mcp23008:
- id: "mcp23008_hub"
address: 0x20
i2c:
sda: GPIO1 # Tx Blue
scl: GPIO3 # Rx Green
# scan: true
binary_sensor:
- platform: gpio
id: button1
filters:
- delayed_on_off: 100ms
pin:
mcp23xxx: mcp23008_hub
number: 0
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- if:
condition:
and:
- lambda: "return id(speed).state == 1;"
- switch.is_on: master
then:
- switch.turn_off: master
else:
- number.set:
id: speed
value: 1
- switch.turn_on: master
- platform: gpio
id: button2
filters:
- delayed_on_off: 100ms
pin:
mcp23xxx: mcp23008_hub
number: 1
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- if:
condition:
and:
- lambda: "return id(speed).state == 2;"
- switch.is_on: master
then:
- switch.turn_off: master
else:
- number.set:
id: speed
value: 2
- switch.turn_on: master
- platform: gpio
id: button3
filters:
- delayed_on_off: 100ms
pin:
mcp23xxx: mcp23008_hub
number: 2
mode: INPUT_PULLUP
inverted: true
on_press:
then:
- if:
condition:
and:
- lambda: "return id(speed).state == 3;"
- switch.is_on: master
then:
- switch.turn_off: master
else:
- number.set:
id: speed
value: 3
- switch.turn_on: master
number:
- platform: template
name: Fan ${name} speed
id: speed
icon: mdi:fan
update_interval: never
optimistic: true
min_value: 1
max_value: 3
initial_value: 1
step: 1
set_action:
- if:
condition:
- switch.is_on: master
then:
- lambda: >-
if (x == 1) {return id(relay1).turn_on();}
- lambda: >-
if (x == 2) {return id(relay2).turn_on();}
- lambda: >-
if (x == 3) {return id(relay3).turn_on();}
switch:
- platform: template
id: master
icon: mdi:fan
name: Fan ${name} master
optimistic: true
on_turn_on:
then:
- lambda: >-
if (id(speed).state == 1) {return id(relay1).turn_on();}
- lambda: >-
if (id(speed).state == 2) {return id(relay2).turn_on();}
- lambda: >-
if (id(speed).state == 3) {return id(relay3).turn_on();}
on_turn_off:
- lambda: "id(relay1).turn_off();"
- lambda: "id(relay2).turn_off();"
- lambda: "id(relay3).turn_off();"
- platform: gpio
id: internal_relay
pin: GPIO12
- platform: gpio
id: relay1
pin:
mcp23xxx: mcp23008_hub
number: 5
mode: OUTPUT
inverted: true
interlock: &interlock_group [relay1, relay2, relay3]
interlock_wait_time: 250ms
on_turn_on:
- switch.turn_on: internal_relay
- number.set:
id: speed
value: 1
on_turn_off:
- switch.turn_off: internal_relay
- platform: gpio
id: relay2
pin:
mcp23xxx: mcp23008_hub
number: 6
mode: OUTPUT
inverted: true
interlock: *interlock_group
interlock_wait_time: 250ms
on_turn_on:
- number.set:
id: speed
value: 2
- platform: gpio
id: relay3
pin:
mcp23xxx: mcp23008_hub
number: 7
mode: OUTPUT
inverted: true
interlock: *interlock_group
interlock_wait_time: 250ms
on_turn_on:
- number.set:
id: speed
value: 3
status_led:
pin:
number: GPIO13
inverted: yes