forked from edwardmp/ESPHome-Zehnder-RF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utility-bridge.yaml
262 lines (237 loc) · 6.66 KB
/
utility-bridge.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
262
substitutions:
hostname: zehnder-comfofan
device_name: Zehnder ComfoFan
device_id: zehnder_comfofan
esphome:
name: ${hostname}
comment: ${device_name}
esp32:
board: esp32doit-devkit-v1
framework:
type: arduino
# Enable logging
logger:
level: INFO
preferences:
flash_write_interval: 1d
# Enable Home Assistant API
api:
encryption:
key: !secret "zehnder_comfofan_api_key"
services:
- service: set_speed
variables:
run_speed: int
run_time: int
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(run_speed, run_time);
- service: set_mode
variables:
mode: string
then:
- lambda: |-
if (mode == "Auto") {
id(${device_id}_ventilation).setSpeed(0, 0);
} else if (mode == "Low") {
id(${device_id}_ventilation).setSpeed(1, 0);
} else if (mode == "Medium") {
id(${device_id}_ventilation).setSpeed(2, 0);
} else if (mode == "High") {
id(${device_id}_ventilation).setSpeed(3, 0);
} else if (mode == "Max_10m") {
id(${device_id}_ventilation).setSpeed(4, 10);
} else if (mode == "Max_30m") {
id(${device_id}_ventilation).setSpeed(4, 30);
} else if (mode == "Max_60m") {
id(${device_id}_ventilation).setSpeed(4, 60);
} else {
ESP_LOGW("zehnder", "Unknown mode %s", mode.c_str());
}
ota:
- platform: esphome
password: !secret "zehnder_comfofan_ota_password"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
# Enable fallback hotspot (captive portal) in case Wifi connection fails
ap:
ssid: "${device_name} hotspot"
password: !secret "zehnder_comfofan_ap_password"
captive_portal:
web_server:
port: 80
local: true
auth:
username: admin
password: !secret "zehnder_comfofan_web_password"
time:
- platform: sntp
timezone: Europe/Amsterdam
servers:
- "pool.ntp.org"
binary_sensor:
- platform: template
name: "${device_name} Timer"
id: "${device_id}_timer"
icon: mdi:fan-clock
lambda: !lambda 'return id(${device_id}_ventilation).timer;'
sensor:
- platform: wifi_signal
name: "${device_name} RSSI"
id: "${device_id}_rssi"
- platform: uptime
name: "${device_name} Uptime"
id: "${device_id}_uptime"
- platform: template
name: "${device_name} Ventilation Percentage"
id: "${device_id}_ventilation_percentage"
state_class: measurement
unit_of_measurement: '%'
icon: mdi:percent
accuracy_decimals: 0
update_interval: 15s
lambda: !lambda 'return id(${device_id}_ventilation).voltage;'
- platform: template
name: "${device_name} Error Status"
id: "${device_id}_error_status"
state_class: measurement
icon: mdi:alert-circle
accuracy_decimals: 0
update_interval: 15s
lambda: !lambda 'return id(${device_id}_ventilation).get_error_status();'
text_sensor:
- platform: wifi_info
ip_address:
name: "${device_name} IP Address"
id: "${device_id}_ip_address"
ssid:
name: "${device_name} SSID"
id: "${device_id}_ssid"
bssid:
name: "${device_name} BSSID"
id: "${device_id}_bssid"
mac_address:
name: "${device_name} MAC"
id: "${device_id}_mac"
- platform: template
name: "${device_name} Ventilation Mode"
id: "${device_id}_ventilation_mode"
update_interval: 15s
icon: mdi:information
lambda: |-
switch (id(${device_id}_ventilation).speed) {
case 1: return {"Low"};
case 2: return {"Medium"};
case 3: return {"High"};
case 4: return {"Max"};
default: return {"Auto"};
}
switch:
- platform: safe_mode
name: "${device_name} Restart (Safe Mode)"
- platform: restart
name: "${device_name} Restart"
button:
- platform: template
id: ${device_id}_auto
name: ${device_name} Auto
icon: mdi:fan-auto
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(0, 0);
- platform: template
id: ${device_id}_low
name: ${device_name} Low
icon: mdi:fan-speed-1
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(1, 0);
- platform: template
id: ${device_id}_medium
name: ${device_name} Medium
icon: mdi:fan-speed-2
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(2, 0);
- platform: template
id: ${device_id}_high
name: ${device_name} High
icon: mdi:fan-speed-3
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(3, 0);
- platform: template
id: ${device_id}_max_10
name: ${device_name} Max 10
icon: mdi:fast-forward-10
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(4, 10);
- platform: template
id: ${device_id}_max_30
name: ${device_name} Max 30
icon: mdi:fast-forward-30
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(4, 30);
- platform: template
id: ${device_id}_max_60
name: ${device_name} Max 60
icon: mdi:fast-forward-60
on_press:
then:
- lambda: |-
id(${device_id}_ventilation).setSpeed(4, 60);
# Load external components
external_components:
- source: github://TimelessNL/ESPHome-Zehnder-RF
components: [ nrf905, zehnder ]
refresh: 0s
# SPI
spi:
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO16
# nRF905 config
nrf905:
id: "nrf905_rf"
cs_pin: GPIO15
cd_pin: GPIO33
ce_pin: GPIO27
pwr_pin: GPIO26
txen_pin: GPIO25
# The FAN controller
fan:
- platform: zehnder
id: ${device_id}_ventilation
name: "${device_name} Ventilation"
nrf905: nrf905_rf
update_interval: "15s"
on_speed_set:
- sensor.template.publish:
id: ${device_id}_ventilation_percentage
state: !lambda 'return id(${device_id}_ventilation).voltage;'
- binary_sensor.template.publish:
id: ${device_id}_timer
state: !lambda 'return id(${device_id}_ventilation).timer;'
- text_sensor.template.publish:
id: ${device_id}_ventilation_mode
state: !lambda |-
switch (id(${device_id}_ventilation).speed) {
case 1: return {"Low"};
case 2: return {"Medium"};
case 3: return {"High"};
case 4: return {"Max"};
default: return {"Auto"};
}
- sensor.template.publish:
id: ${device_id}_error_status
state: !lambda 'return id(${device_id}_ventilation).get_error_status();'