-
Notifications
You must be signed in to change notification settings - Fork 1
/
Airleaf.yaml
608 lines (564 loc) · 15.4 KB
/
Airleaf.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
substitutions:
devicename: airleaf-01
#devicename: airleaf-01b
#devicename: airleaf-02
esphome:
name: $devicename
esp8266:
board: d1_mini
logger:
# No log output through UART
baud_rate: 0
# Enable Home Assistant API
api:
ota:
- platform: esphome
password: !secret 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: $devicename
password: !secret ap_password
captive_portal:
uart:
tx_pin: 1
rx_pin: 3
baud_rate: 9600
modbus:
modbus_controller:
- id: airleaf
address: 0x1
climate:
- platform: thermostat
name: "Airleaf Climate"
id: airleaf_climate
sensor: air_temperature
set_point_minimum_differential: 2
cool_action:
- logger.log: "Cooling activated"
min_cooling_off_time: 1s
min_cooling_run_time: 1s
heat_action:
- logger.log: "Heating activated"
min_heating_off_time: 1s
min_heating_run_time: 1s
idle_action:
- logger.log: "Idle activated"
min_idle_time: 1s
# auto_mode:
# - select.set:
# id: season
# option: "Auto"
off_mode:
- if:
condition:
lambda: 'return id(fan_mode).state != "Standby";'
then:
- select.set:
id: fan_mode
option: "Standby"
heat_mode:
- if:
condition:
lambda: 'return id(season).state != "Winter";'
then:
- select.set:
id: season
option: "Winter"
cool_mode:
- if:
condition:
lambda: 'return id(season).state != "Summer";'
then:
- select.set:
id: season
option: "Summer"
fan_mode_auto_action:
- if:
condition:
lambda: 'return id(fan_mode).state != "Auto";'
then:
- select.set:
id: fan_mode
option: "Auto"
fan_mode_quiet_action:
- if:
condition:
lambda: 'return id(fan_mode).state != "Night";'
then:
- select.set:
id: fan_mode
option: "Night"
fan_mode_low_action:
- if:
condition:
lambda: 'return id(fan_mode).state != "Low";'
then:
- select.set:
id: fan_mode
option: "Low"
fan_mode_high_action:
- if:
condition:
lambda: 'return id(fan_mode).state != "High";'
then:
- select.set:
id: fan_mode
option: "High"
min_fan_mode_switching_time: 1s
target_temperature_change_action:
# Sync temperature setpoint with changed thermostat dial
- if:
condition:
lambda: "return id(airleaf_climate).mode == CLIMATE_MODE_COOL && id(airleaf_climate).target_temperature_high != id(target_temperature).state;"
then:
- number.set:
id: target_temperature
value: !lambda "return id(airleaf_climate).target_temperature_high;"
- if:
condition:
lambda: "return id(airleaf_climate).mode == CLIMATE_MODE_HEAT && id(airleaf_climate).target_temperature_low != id(target_temperature).state;"
then:
- number.set:
id: target_temperature
value: !lambda "return id(airleaf_climate).target_temperature_low;"
default_preset: home
preset:
- name: home
fan_mode: auto
default_target_temperature_low: 20 °C
default_target_temperature_high: 25 °C
- name: eco
fan_mode: auto
default_target_temperature_low: 19 °C
default_target_temperature_high: 26 °C
- name: comfort
fan_mode: auto
default_target_temperature_low: 21 °C
default_target_temperature_high: 24 °C
- name: sleep
fan_mode: quiet
default_target_temperature_low: 20 °C
default_target_temperature_high: 25 °C
- name: boost
fan_mode: high
default_target_temperature_low: 21 °C
default_target_temperature_high: 24 °C
sensor:
- platform: wifi_signal
name: rssi
update_interval: 60s
- platform: modbus_controller
name: Air Temperature
id: air_temperature
register_type: read
address: 0
# Prevent reading register at address 1 at the same time
force_new_range: true
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: Water Temperature
icon: "mdi:coolant-temperature"
register_type: read
address: 1
force_new_range: true
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
name: Fan speed
icon: "mdi:speedometer"
register_type: read
address: 15
unit_of_measurement: "RPM"
device_class: frequency
state_class: measurement
value_type: U_WORD
text_sensor:
- platform: modbus_controller
name: Status flags
icon: "mdi:flag"
entity_category: diagnostic
register_type: read
address: 104
force_new_range: true
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("No flags");
case 1: return std::string("Cooling");
case 2: return std::string("Heating");
case 16: return std::string("Water T");
case 64: return std::string("Bad water");
case 256: return std::string("Away mode");
case 512: return std::string("Alarm");
case 1024: return std::string("Testing");
case 2048: return std::string("Standby");
case 8192: return std::string("H2 absent");
default: return x;
}
return x;
- platform: modbus_controller
name: Alarm flags
icon: "mdi:alert-circle-outline"
entity_category: diagnostic
register_type: read
address: 105
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("OK");
case 1: return std::string("Comm");
case 2: return std::string("Air probe");
case 8: return std::string("Bad water");
case 16: return std::string("Water probe");
case 64: return std::string("HiZ");
case 128: return std::string("Motor");
case 256: return std::string("Grid");
case 512: return std::string("Water T");
case 1024: return std::string("Filter");
default: return x;
}
return x;
- platform: modbus_controller
name: Relay status
icon: "mdi:dip-switch"
entity_category: diagnostic
register_type: read
address: 9
#response_size: 1
#offset: 1
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("All off");
case 1: return std::string("EV1");
case 2: return std::string("EV2");
case 3: return std::string("EV1|EV2");
case 4: return std::string("Chiller");
case 5: return std::string("Chiller|EV1");
case 7: return std::string("Chiller|EV1|EV2");
case 8: return std::string("Heater");
case 9: return std::string("Heater|EV1");
case 11: return std::string("Heater|EV1|EV2");
default: return x;
}
return x;
number:
- platform: modbus_controller
id: target_temperature
name: Temperature
mode: slider
icon: "mdi:thermometer"
entity_category: config
unit_of_measurement: "°C"
device_class: temperature
address: 231
value_type: U_WORD
min_value: 16.0
max_value: 25.0
step: 0.5
# Read old value from register
lambda: "return x * 0.1;"
# Write new value to register
write_lambda: "return x * 10;"
on_value:
# Sync thermostat dial with changed setpoint temperature
then:
- if:
condition:
lambda: 'return id(airleaf_climate).mode == CLIMATE_MODE_COOL;'
then:
- climate.control:
id: airleaf_climate
target_temperature_high: !lambda "return x;"
else:
- climate.control:
id: airleaf_climate
target_temperature_low: !lambda "return x;"
- platform: modbus_controller
name: Device Address
mode: box
icon: "mdi:id-card"
entity_category: config
address: 200
force_new_range: true
value_type: U_WORD
min_value: 1
max_value: 255
step: 1
lambda: "return x;"
write_lambda: "return x;"
- platform: modbus_controller
name: Min heating water T
mode: box
icon: "mdi:thermometer-chevron-up"
entity_category: config
device_class: frequency
address: 218
force_new_range: true
value_type: U_WORD
min_value: 22.0
max_value: 35.0
step: 0.5
lambda: "return x * 0.1;"
write_lambda: "return x * 10;"
- platform: modbus_controller
name: Max cooling water T
mode: box
icon: "mdi:thermometer-chevron-down"
entity_category: config
device_class: frequency
address: 219
value_type: U_WORD
min_value: 15.0
max_value: 20.0
step: 0.5
lambda: "return x * 0.1;"
write_lambda: "return x * 10;"
# Minimum speed in MIN and Night mode (400)
- platform: modbus_controller
name: Min fan speed (Night)
mode: box
icon: "mdi:fan-speed-1"
entity_category: config
device_class: frequency
address: 210
force_new_range: true
value_type: U_WORD
min_value: 200
max_value: 680
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in Night Mode and Minimum in AUTO (550)
- platform: modbus_controller
name: Min fan speed
mode: box
icon: "mdi:fan-auto"
entity_category: config
device_class: frequency
address: 211
force_new_range: true
value_type: U_WORD
min_value: 300
max_value: 1100
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in MIN and Minimum in MAX (680)
- platform: modbus_controller
name: Min fan speed (MAX)
mode: box
icon: "mdi:fan-speed-3"
entity_category: config
device_class: frequency
address: 212
force_new_range: true
value_type: U_WORD
min_value: 400
max_value: 1100
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in AUTO (1100)
- platform: modbus_controller
name: Max fan speed
mode: box
icon: "mdi:fan-auto"
entity_category: config
device_class: frequency
address: 213
force_new_range: true
value_type: U_WORD
min_value: 550
max_value: 1500
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in MAX (1500)
- platform: modbus_controller
name: Max fan speed (MAX)
mode: box
icon: "mdi:fan-speed-3"
entity_category: config
device_class: frequency
address: 214
force_new_range: true
value_type: U_WORD
min_value: 550
max_value: 1500
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in MAX with Performance enabled (1700)
- platform: modbus_controller
name: Max fan speed (MAX Perf)
mode: box
icon: "mdi:fan-chevron-up"
entity_category: config
device_class: frequency
address: 215
value_type: U_WORD
min_value: 550
max_value: 1700
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in MIN and Minimum in MAX with Performance enabled (920)
- platform: modbus_controller
name: Max fan speed (MIN)
mode: box
icon: "mdi:fan-speed-1"
entity_category: config
device_class: frequency
address: 230
force_new_range: true
value_type: U_WORD
min_value: 550
max_value: 1500
step: 10
lambda: "return x;"
write_lambda: "return x;"
# Maximum speed in AUTO with Performance enabled (1220)
- platform: modbus_controller
name: Max fan speed (AUTO Perf)
mode: box
icon: "mdi:fan-chevron-up"
entity_category: config
device_class: frequency
address: 234
value_type: U_WORD
min_value: 550
max_value: 1500
step: 10
lambda: "return x;"
write_lambda: "return x;"
- platform: modbus_controller
name: Air probe offset
mode: box
icon: "mdi:compare-vertical"
entity_category: config
address: 242
force_new_range: true
value_type: S_WORD
min_value: -12
max_value: 12
step: 0.1
lambda: "return x * 0.1;"
write_lambda: "return x * 10;"
select:
- platform: modbus_controller
name: Fan mode
id: fan_mode
icon: "mdi:fan"
entity_category: config
address: 201
force_new_range: true
value_type: U_WORD
optionsmap:
"Auto": 0
"Low": 1
"Night": 2
"High": 3
"Standby": 128
# Sync current option with register
#lambda: "return {};"
# Write (numeric) value to register
#write_lambda: "return value;"
# Sync climate component
on_value:
# Sync thermostat with changed fan mode
then:
- climate.control:
id: airleaf_climate
fan_mode: !lambda |-
static std::map<std::string, climate::ClimateFanMode> mode_map {
{"Auto", CLIMATE_FAN_AUTO},
{"Low", CLIMATE_FAN_LOW},
{"Night", CLIMATE_FAN_QUIET},
{"High", CLIMATE_FAN_HIGH},
{"Standby", CLIMATE_FAN_OFF}
};
return mode_map[x];
- platform: modbus_controller
name: Season
id: season
icon: "mdi:sun-snowflake"
entity_category: config
address: 233
force_new_range: true
value_type: U_WORD
optionsmap:
# "Auto": 0
"Winter": 3
"Summer": 5
#lambda: "return {};"
#write_lambda: "return value;"
on_value:
# Sync thermostat with changed season
then:
- climate.control:
id: airleaf_climate
mode: !lambda |-
static std::map<std::string, climate::ClimateMode> mode_map {
{"Winter", CLIMATE_MODE_HEAT},
{"Summer", CLIMATE_MODE_COOL}
};
return mode_map[x];
switch:
- platform: template
name: Standby
id: standby_switch
icon: "mdi:power-standby"
entity_category: config
lambda: |-
auto val = id(fan_mode).state;
return val == "Standby";
turn_on_action:
- lambda: |-
id(fan_mode_state) = id(fan_mode).state;
- select.set:
id: fan_mode
option: "Standby"
turn_off_action:
- select.set:
id: fan_mode
option: !lambda |-
return id(fan_mode_state);
- platform: template
name: Night mode
icon: "mdi:weather-night"
lambda: |-
auto val = id(fan_mode).state;
return val == "Night";
turn_on_action:
- select.set:
id: fan_mode
option: "Night"
turn_off_action:
- select.set:
id: fan_mode
option: "Auto"
- platform: restart
name: Restart
globals:
- id: fan_mode_state
type: std::string
#initial_value: "Auto"