-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTERMOSTATO NEXTION ESPHOME LOGICA ON OFF MANUALE OFFLINE.txt
297 lines (255 loc) · 7.33 KB
/
TERMOSTATO NEXTION ESPHOME LOGICA ON OFF MANUALE OFFLINE.txt
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
esphome:
name: termostato
platform: ESP8266
board: d1_mini_lite
wifi:
ssid: "TP-LINK_2ACBA2"
password: "14059001"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Termostato Fallback Hotspot"
password: "vQRwCb46VrWg"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
dallas:
- pin: GPIO5
#0x0E041623899DFF28
switch:
- platform: gpio
name: "Heating"
id: "Heating_D3"
pin: GPIO4
sensor:
- platform: dallas
address: 0x0E041623899DFF28
name: "Temperatura"
id: temp_dallas_1
- platform: homeassistant #configuration.yaml sensor for the "set temperature" value
entity_id: sensor.set_temp
id: set_temperature
- platform: template
name: "Set Temperature"
lambda: |-
id(set_temp) = id(set_temperature).state;
return id(set_temp);
update_interval: 600ms
- platform: uptime
name: Uptime Sensor Termostato
- platform: wifi_signal
name: "WiFi Signal Termostato"
update_interval: 60s
text_sensor:
- platform: homeassistant #configuration.yaml sensor for the state of the thermostat
entity_id: sensor.hvac_mode
id: hvac_mode
- platform: template
name: "blocco"
id: blocco_stato
internal: true
interval:
- interval: 5s
then:
- if:
condition:
api.connected:
then:
lambda: |-
if (id(nex_page)==10){
}else{
id(nex_page) = 11;
}
else:
lambda: |-
if (id(nex_page)==8){
}else{
id(nex_page) = 9;
}
time:
- platform: homeassistant
id: homeassistant_time
sun:
latitude: 37.6797065
longitude: 13.5995194
on_sunrise:
- elevation: 2°
then:
lambda: |-
id(brightness)=1;
on_sunset:
then:
lambda: |-
id(brightness)=3;
display:
- platform: nextion
id: clima_nextion
update_interval: 300ms
lambda: |-
// Do not wait for ACK - it slows down the process, and has no use
it.set_wait_for_ack(false);
//blocco le scritture temp sul display se non cambia
if (id(temp_dallas_1).state != id(blocco_temp)){
it.set_component_text_printf("temp","%.1f",id(temp_dallas_1).state); //Set the sensor's temperature on the display
it.set_component_text_printf("temp_page1","%.1f",id(temp_dallas_1).state); //Set the sensor's temperature on the display
}
id(blocco_temp) = id(temp_dallas_1).state;
if (id(set_temp) != id(blocco_set)){
it.set_component_text_printf("setpoint","%.1f",id(set_temperature).state); //Set the sensor's temperature on the display
}
id(blocco_set) = id(set_temp);
if (id(hvac_mode).state != id(blocco_stato).state){
if (id(hvac_mode).state == "off") {
it.send_command_printf ("b0.picc=1");
it.send_command_printf ("b1.picc=0");
it.send_command_printf ("t3.picc=0");
it.set_component_text_printf("stato","%s","Spento"); //set the state of the heater on the display
}
if (id(hvac_mode).state == "heating"){
it.send_command_printf ("b0.picc=0");
it.send_command_printf ("b1.picc=1");
it.send_command_printf ("t3.picc=1");
it.set_component_text_printf("stato","%s","Riscaldamenti"); //set the state of the heater on the display
}
if (id(hvac_mode).state == "idle"){
it.send_command_printf ("b0.picc=0");
it.send_command_printf ("b1.picc=1");
it.send_command_printf ("t3.picc=2");
it.set_component_text_printf("stato","%s","Inattivo"); //set the state of the heater on the display
}
id(blocco_stato).state = id(hvac_mode).state;
}
if (id(on_off_manual) != id(blocco_manual)) {
if (id(Heating_D3).state) {
it.send_command_printf ("b3.picc=1");
it.send_command_printf ("b2.picc=0");
it.set_component_text_printf("stato1","%s","Accesi"); //set the state of the heater on the display
}else{
it.send_command_printf ("b3.picc=0");
it.send_command_printf ("b2.picc=1");
it.set_component_text_printf("stato1","%s","Spenti"); //set the state of the heater on the display
}
id(blocco_manual) = id(on_off_manual);
}
- platform: nextion
id: nextion_stamp_ora
update_interval: 40s
lambda: |-
auto data_text = id(homeassistant_time).now().strftime("%d-%m-%Y-%H:%M");
it.set_component_text("data", data_text.c_str());
auto time_text = id(homeassistant_time).now().strftime("%H:%M");
it.set_component_text("t0", time_text.c_str());
- platform: nextion
id: nextion_brightness
update_interval: 10s
lambda: |-
if (id(brightness) <2){
it.set_backlight_brightness (100);
}
if (id(brightness) >2){
it.set_backlight_brightness (10);
}
- platform: nextion
update_interval: 5s
id: nextion_page
lambda: |-
if (id(nex_page)==11) {
it.goto_page ( "page0");
id(nex_page) = 10;
}
if (id(nex_page)==9) {
it.goto_page ( "page1");
id(nex_page) = 8;
}
binary_sensor:
- platform: status
name: "ESP TERMOSTATO"
- platform: nextion
page_id: 0
component_id: 6
id: set_up
name: "set up"
on_release:
lambda: |-
id(set_temp) = id(set_temp) + 0.5;
if (id(set_temp) == 31){
id(set_temp) = 30.0;
}
- platform: nextion
page_id: 0
component_id: 7
id: set_down
name: "set down"
on_release:
lambda: |-
id(set_temp) = id(set_temp) - 0.5;
if (id(set_temp) == 14) {
id(set_temp) = 15.0;
}
- platform: nextion
page_id: 0
component_id: 4
id: heater_off
name: "Turn Heater Off"
- platform: nextion
page_id: 0
component_id: 5
id: heater_on
name: "Turn Heater On"
- platform: nextion
page_id: 1
component_id: 2
id: heater_off_local
name: "Turn Heater Off"
on_release:
- then:
- switch.turn_off: Heating_D3
- then:
lambda: |-
id(on_off_manual) = 0;
- platform: nextion
page_id: 1
component_id: 3
id: heater_on_local
name: "Turn Heater On"
on_release:
- then:
- switch.turn_on: Heating_D3
- then:
lambda: |-
id(on_off_manual) = 1;
uart:
rx_pin: GPIO3
tx_pin: GPIO2
baud_rate: 9600
globals:
- id: set_temp
type: float
initial_value: '15.0'
restore_value: no
- id: nex_page
type: int
initial_value: '11'
restore_value: no
- id: on_off_manual
type: int
initial_value: '0'
restore_value: no
- id: brightness
type: int
initial_value: '0'
restore_value: yes
- id: blocco_manual
type: int
initial_value: '3'
restore_value: yes
- id: blocco_temp
type: float
initial_value: '0.0'
restore_value: yes
- id: blocco_set
type: float
initial_value: '0.0'
restore_value: yes