-
Notifications
You must be signed in to change notification settings - Fork 0
/
airco_woonkamer.yaml
282 lines (263 loc) · 9.37 KB
/
airco_woonkamer.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
substitutions:
deviceid: "airco_woonkamer"
device_description: ESPHome MHI-AC-Ctrl-ESPHome
friendly_name: "Airco woonkamer"
# Unique MHI device ID used for climate class
mhi_device_id: "mhi_${deviceid}"
# Unique device name in HA (sensor names will be prefixed by this name)
devicename: ${deviceid}
# If you encounter mhi_ac_ctrl_core.loop error: -2 errors, change the frame_size to 20
frame_size: "33"
################ Generics ################
esphome:
name: ${deviceid}
friendly_name: ${friendly_name}
comment: "${device_description}"
platformio_options:
# Run CPU at 160Mhz to fix mhi_ac_ctrl_core.loop error: -2
board_build.f_cpu: 160000000L
esp8266:
board: d1_mini
wifi:
manual_ip:
static_ip: !secret wifi_static_ip_airco_woonkamer
# General settings: captive portal, logger, api, ota, time, restart switch, wifi
# General sensors: status, uptime, version, wifi info etc
packages:
general_settings: !include includes/general_settings.yaml
general_sensors: !include includes/general_sensors.yaml
web_server:
################ Components ################
external_components:
- source: github://ginkage/MHI-AC-Ctrl-ESPHome@master
components: [MhiAcCtrl]
MhiAcCtrl:
id: ${mhi_device_id}
frame_size: ${frame_size}
api:
reboot_timeout: 0s
services:
# Call the set_api_room_temperature service from HA to override the room temperature
# If a new value has not been received after room_temp_api_timeout seconds, it will fall back to internal sensor
- service: set_api_room_temperature
variables:
value: float
then:
- lambda: |-
return ((MhiAcCtrl*)id(${deviceid}))->set_room_temperature(value);
# Call the set_vanes service from HA to set the vane position
# Needed because the ESPHome Climate class does not support this natively
# Possible values: 1-4: static positions, 5: swing, 0: unknown
- service: set_vanes
variables:
value: int
then:
- lambda: |-
return ((MhiAcCtrl*)id(${deviceid}))->set_vanes(value);
globals:
- id: room_temp_api_timeout
type: int
restore_value: no
initial_value: "120"
- id: frame_size
type: byte
restore_value: no
initial_value: "33"
climate:
- platform: MhiAcCtrl
mhi_ac_ctrl_id: ${mhi_device_id}
id: ${deviceid}
name: "${devicename}"
sensor:
- platform: custom
lambda: |-
return ((MhiAcCtrl*)id(${deviceid}))->get_sensors();
# Sensor names in HA, you can change these if you want
# Don't delete them or change their position in the list
sensors:
- name: Error code
- name: Outdoor temperature
- name: Return air temperature
- name: Outdoor unit fan speed
- name: Indoor unit fan speed
- name: Current power
- name: Compressor frequency
- name: Indoor unit total run time
- name: Compressor total run time
- name: Vanes
id: vanes_UD_received
on_value:
then:
- lambda: |-
float received_value = id(vanes_UD_received).state;
if (received_value == 1.0) {
id(fan_control_ud).publish_state("Up");
} else if (received_value == 2.0) {
id(fan_control_ud).publish_state("Up/Center");
} else if (received_value == 3.0) {
id(fan_control_ud).publish_state("Center/Down");
} else if (received_value == 4.0) {
id(fan_control_ud).publish_state("Down");
} else if (received_value == 5.0) {
id(fan_control_ud).publish_state("Swing");
}
- name: Energy used
- name: Indoor (U-bend) HE temp 1
- name: Indoor (capillary) HE temp 2
- name: Indoor (suction header) HE temp 3
- name: Outdoor HE temp
- name: Outdoor unit exp. valve
- name: Outdoor unit discharge pipe
- name: Outdoor unit discharge pipe super heat
- name: Compressor protection code
- name: Vanes Left Right
id: vanes_LR_received
on_value:
then:
- lambda: |-
float received_value = id(vanes_LR_received).state;
if (received_value == 1.0) {
id(fan_control_lr).publish_state("Left");
} else if (received_value == 2.0) {
id(fan_control_lr).publish_state("Left/Center");
} else if (received_value == 3.0) {
id(fan_control_lr).publish_state("Center");
} else if (received_value == 4.0) {
id(fan_control_lr).publish_state("Center/Right");
} else if (received_value == 5.0) {
id(fan_control_lr).publish_state("Right");
} else if (received_value == 6.0) {
id(fan_control_lr).publish_state("Wide");
} else if (received_value == 7.0) {
id(fan_control_lr).publish_state("Spot");
} else if (received_value == 8.0) {
id(fan_control_lr).publish_state("Swing");
}
- name: 3D Auto
id: Dauto_received
on_value:
then:
- lambda: |-
bool received_value = id(Dauto_received).state;
if (received_value) {
ESP_LOGD("main", "received 3DAuto from AC");
id(fan_control_3Dauto).publish_state(true);
}
else {
ESP_LOGD("main", "received 3DAuto off from AC");
id(fan_control_3Dauto).publish_state(false);
}
select:
- platform: template
name: Fan Control Left Right
id: fan_control_lr
icon: mdi:arrow-left-right
optimistic: true
options:
# - "3D Auto"
- "Left"
- "Left/Center"
- "Center"
- "Center/Right"
- "Right"
- "Wide"
- "Spot"
- "Swing"
on_value:
- lambda: |-
auto state = id(fan_control_lr).state.c_str();
ESP_LOGD("main", "Option of my select: %s", state);
uint8_t vanesLR = 0; // Initialize the vanesLR variable
if (id(fan_control_lr).state == "3D Auto") {
id(fan_control_3Dauto).publish_state(true);
} else if (id(fan_control_lr).state == "Left") {
vanesLR = 1;
} else if (id(fan_control_lr).state == "Left/Center") {
vanesLR = 2;
} else if (id(fan_control_lr).state == "Center") {
vanesLR = 3;
} else if (id(fan_control_lr).state == "Center/Right") {
vanesLR = 4;
} else if (id(fan_control_lr).state == "Right") {
vanesLR = 5;
} else if (id(fan_control_lr).state == "Wide") {
vanesLR = 6;
} else if (id(fan_control_lr).state == "Spot") {
vanesLR = 7;
} else if (id(fan_control_lr).state == "Swing") {
vanesLR = 8;
}
if ((vanesLR > 0) & (vanesLR < 9) & (vanesLR != id(vanes_LR_received).state)){
ESP_LOGD("main", "setting vanesLR to: %i", vanesLR);
return ((MhiAcCtrl*)id(${deviceid}))->set_vanesLR(vanesLR);
}
else {
ESP_LOGD("main", "Not setting vanesLR: %i", vanesLR);
}
- platform: template
name: Fan Control Up Down
id: fan_control_ud
icon: mdi:arrow-up-down
optimistic: true
options:
# - "3D Auto"
- "Up"
- "Up/Center"
- "Center/Down"
- "Down"
- "Swing"
on_value:
- lambda: |-
auto state = id(fan_control_ud).state.c_str();
ESP_LOGD("main", "Option of my select: %s", state);
uint8_t vanesUD = 0; // Initialize the vanesUD variable
if (id(fan_control_ud).state == "3D Auto") {
id(fan_control_3Dauto).publish_state(true);
} else if (id(fan_control_ud).state == "Up") {
vanesUD = 1;
} else if (id(fan_control_ud).state == "Up/Center") {
vanesUD = 2;
} else if (id(fan_control_ud).state == "Center/Down") {
vanesUD = 3;
} else if (id(fan_control_ud).state == "Down") {
vanesUD = 4;
} else if (id(fan_control_ud).state == "Swing") {
vanesUD = 5;
}
if ((vanesUD > 0) & (vanesUD < 6) & (vanesUD != id(vanes_UD_received).state)){
ESP_LOGD("main", "setting vanesUD to: %i", vanesUD);
return ((MhiAcCtrl*)id(${deviceid}))->set_vanes(vanesUD);
}
else {
ESP_LOGD("main", "Not setting vanesUD: %i", vanesUD);
}
switch:
- platform: template
name: 3D Auto
id: fan_control_3Dauto
icon: mdi:video-3d
optimistic: true
turn_on_action:
- lambda: |-
if (id(Dauto_received).state !=1){
ESP_LOGD("main", "Turn on 3DAuto");
return ((MhiAcCtrl*)id(${deviceid}))->set_3Dauto(1);
}
turn_off_action:
- lambda: |-
if (id(Dauto_received).state !=0){
ESP_LOGD("main", "Turn off 3DAuto");
return ((MhiAcCtrl*)id(${deviceid}))->set_3Dauto(0);
}
binary_sensor:
- platform: custom
lambda: |-
return ((MhiAcCtrl*)id(${deviceid}))->get_binary_sensors();
binary_sensors:
- name: Defrost
text_sensor:
- platform: custom
lambda: |-
return ((MhiAcCtrl*)id(${deviceid}))->get_text_sensors();
text_sensors:
- name: Compressor protection status