├── NEXTION_THERMOSTAT_HOME_ASSISTANTON OFF_OFFLINE.HMI ├── configuration.yaml.txt ├── README.md ├── automation.yaml.txt └── TERMOSTATO NEXTION ESPHOME LOGICA ON OFF MANUALE OFFLINE.txt /NEXTION_THERMOSTAT_HOME_ASSISTANTON OFF_OFFLINE.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Giuseppe-P/Thermostat_Esphome-Home-Assistant_Nextion-3.2-inches_ON-OFF-MANUAL/HEAD/NEXTION_THERMOSTAT_HOME_ASSISTANTON OFF_OFFLINE.HMI -------------------------------------------------------------------------------- /configuration.yaml.txt: -------------------------------------------------------------------------------- 1 | #aggiungi a configuration yaml 2 | 3 | climate: 4 | - platform: generic_thermostat 5 | name: termostato_nextion 6 | heater: switch.Heating 7 | target_sensor: sensor.temp_dallas_1 8 | target_temp: 17 9 | sensor: 10 | - platform: template 11 | sensors: 12 | set_temp: 13 | value_template: "{{states.climate.termostato_nextion.attributes.temperature}}" #get the "set temperature" from lavelace card" 14 | 15 | - platform: template 16 | sensors: 17 | hvac_mode: 18 | value_template: "{{state_attr('climate.termostato_nextion', 'hvac_action')}}" #get the heater state from lavelace card" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | No longer functional. Please refer to the new version 2 | 3 | https://github.com/Giuseppe-P/Climate-thermostat-esphome-nextion 4 | 5 | # Thermostat - Esphome Home Assistant - Nextion-3.2 inches 6 | 7 | This version allows you to manage the thermostat via Home Assistant and in the absence of the server simply ON / OFF in manual mode touch nextion. 8 | To carry out the project with logic even in the absence of Home Assistant and therefore in offline mode, I refer you to the specific version, always in my repository. Link project later 9 | 10 | ![IMG_20200504_171325](https://user-images.githubusercontent.com/15862510/80982771-0c0b6500-8e2c-11ea-923e-0a722314a267.jpg) 11 | ![Manual ON OFF](https://user-images.githubusercontent.com/15862510/80983071-6d333880-8e2c-11ea-8b7c-6b510ea3e4b4.jpg) 12 | ![IMG_20200504_171339](https://user-images.githubusercontent.com/15862510/80982779-0dd52880-8e2c-11ea-992c-8776021a4583.jpg) 13 | ![IMG_20200504_171421](https://user-images.githubusercontent.com/15862510/80982784-0f9eec00-8e2c-11ea-9e0e-151c932e8e59.jpg) 14 | 15 | Home Assistant - Thermostat Touch Nextion - Firmware ESPHOME 16 | 17 | This is a generic Home Assistant thermostat, managed by an ESP8266 chip and a 3.2 "Nextion touch screen panel. 18 | 19 | ESPHOME documentation: 20 | https://esphome.io/index.html 21 | 22 | Home Assistant documentation: 23 | https://www.home-assistant.io/ 24 | 25 | NEXTION documentation: 26 | https://nextion.tech/ 27 | 28 | Hardware needed: 29 | 30 | 1 - RaspberryPi 3 or higher 31 | 32 | 2 - ESP8266-12 chip 33 | 34 | 3 - Touch Screen Panel NEXTION 3.2 pollici 35 | 36 | 4 - relay 5v (ho utilizzato un circuito a transistor, ma potete usare una board pronta) 37 | 38 | 6 - ds18b20 (sensore temperatura) 39 | 40 | 7 - alimentatore da 220v a 5v come in foto 41 | 42 | Software: 43 | 44 | 1 - download and copy home assistant image on sd card for raspberryPi 45 | 46 | 2 - add ESPHOME add on to your Home Assistant 47 | 48 | 3 - upload the firmware to yaml on ESP8266 via Home Assistant add on 49 | 50 | 4 - upload .HMI to next touch panel 51 | 52 | 5 - copy the configuration.yaml content and paste in configuration.yaml in Home Assistant 53 | 54 | 6 - copy the automation.yaml content and paste in automation.yaml in Home Assistant 55 | 56 | Good realization 57 | -------------------------------------------------------------------------------- /automation.yaml.txt: -------------------------------------------------------------------------------- 1 | - id: 'set_positive' #if the "-" button is pressed on the display, set the new value on card, page 0 of desplay 2 | alias: Set Temperature 3 | description: '' 4 | trigger: 5 | - entity_id: binary_sensor.set_down 6 | from: 'off' 7 | platform: state 8 | to: 'on' 9 | condition: [] 10 | action: 11 | - data_template: 12 | temperature: '{{states.sensor.set_temperature.state | float - 0.5}}' 13 | entity_id: climate.termostato_nextion 14 | service: climate.set_temperature 15 | - id: 'set_negative' #if the "+" button is pressed on the display, set the new value on card page 0 of desplay 16 | alias: Set Temperature up 17 | description: '' 18 | trigger: 19 | - entity_id: binary_sensor.set_up 20 | from: 'off' 21 | platform: state 22 | to: 'on' 23 | condition: [] 24 | action: 25 | - data_template: 26 | temperature: '{{states.sensor.set_temperature.state | float + 0.5}}' 27 | entity_id: climate.termostato_nextion 28 | service: climate.set_temperature 29 | - id: 'button_off' #turn the heater off from the power button of the diplay 30 | alias: Turn Heater Off 31 | description: '' 32 | trigger: 33 | - entity_id: binary_sensor.turn_heater_off 34 | from: 'off' 35 | platform: state 36 | to: 'on' 37 | condition: [] 38 | action: 39 | - data_template: 40 | hvac_mode: 'off' 41 | entity_id: climate.termostato_nextion 42 | service: climate.set_hvac_mode 43 | - id: 'button_on' #turn the heater on from the power button of the diplay 44 | alias: Turn Heater ON 45 | description: '' 46 | trigger: 47 | - entity_id: binary_sensor.turn_heater_on 48 | from: 'off' 49 | platform: state 50 | to: 'on' 51 | condition: [] 52 | action: 53 | - data_template: 54 | hvac_mode: heat 55 | entity_id: climate.termostato_nextion 56 | service: climate.set_hvac_mode 57 | - id: 'notification' #send notification for the status change of the heater 58 | alias: Heater mode 59 | description: '' 60 | trigger: 61 | - entity_id: sensor.hvac_mode 62 | from: 'off' 63 | platform: state 64 | to: heating 65 | - entity_id: sensor.hvac_mode 66 | from: 'off' 67 | platform: state 68 | to: idle 69 | - entity_id: sensor.hvac_mode 70 | from: idle 71 | platform: state 72 | to: 'off' 73 | - entity_id: sensor.hvac_mode 74 | from: heating 75 | platform: state 76 | to: 'off' 77 | - entity_id: sensor.hvac_mode 78 | from: heating 79 | platform: state 80 | to: idle 81 | - entity_id: sensor.hvac_mode 82 | from: idle 83 | platform: state 84 | to: heating 85 | condition: [] 86 | action: 87 | - data: 88 | message: Heater is {{state_attr('climate.termostato_nextion', 'hvac_action')}} 89 | title: Heater Status 90 | service: persistent_notification.create 91 | - data: 92 | message: Heater is {{state_attr('climate.termostato_nextion', 'hvac_action')}} 93 | title: Heater Status 94 | service: notify.notify -------------------------------------------------------------------------------- /TERMOSTATO NEXTION ESPHOME LOGICA ON OFF MANUALE OFFLINE.txt: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: termostato 3 | platform: ESP8266 4 | board: d1_mini_lite 5 | 6 | wifi: 7 | ssid: "TP-LINK_2ACBA2" 8 | password: "14059001" 9 | 10 | # Enable fallback hotspot (captive portal) in case wifi connection fails 11 | ap: 12 | ssid: "Termostato Fallback Hotspot" 13 | password: "vQRwCb46VrWg" 14 | 15 | captive_portal: 16 | 17 | # Enable logging 18 | logger: 19 | 20 | # Enable Home Assistant API 21 | api: 22 | 23 | ota: 24 | 25 | 26 | dallas: 27 | - pin: GPIO5 28 | #0x0E041623899DFF28 29 | 30 | 31 | switch: 32 | - platform: gpio 33 | name: "Heating" 34 | id: "Heating_D3" 35 | pin: GPIO4 36 | 37 | sensor: 38 | - platform: dallas 39 | address: 0x0E041623899DFF28 40 | name: "Temperatura" 41 | id: temp_dallas_1 42 | 43 | - platform: homeassistant #configuration.yaml sensor for the "set temperature" value 44 | entity_id: sensor.set_temp 45 | id: set_temperature 46 | 47 | - platform: template 48 | name: "Set Temperature" 49 | lambda: |- 50 | id(set_temp) = id(set_temperature).state; 51 | return id(set_temp); 52 | update_interval: 600ms 53 | 54 | - platform: uptime 55 | name: Uptime Sensor Termostato 56 | 57 | - platform: wifi_signal 58 | name: "WiFi Signal Termostato" 59 | update_interval: 60s 60 | 61 | text_sensor: 62 | - platform: homeassistant #configuration.yaml sensor for the state of the thermostat 63 | entity_id: sensor.hvac_mode 64 | id: hvac_mode 65 | 66 | - platform: template 67 | name: "blocco" 68 | id: blocco_stato 69 | internal: true 70 | 71 | interval: 72 | - interval: 5s 73 | then: 74 | - if: 75 | condition: 76 | api.connected: 77 | then: 78 | lambda: |- 79 | if (id(nex_page)==10){ 80 | }else{ 81 | id(nex_page) = 11; 82 | } 83 | else: 84 | lambda: |- 85 | if (id(nex_page)==8){ 86 | }else{ 87 | id(nex_page) = 9; 88 | } 89 | 90 | time: 91 | - platform: homeassistant 92 | id: homeassistant_time 93 | sun: 94 | latitude: 37.6797065 95 | longitude: 13.5995194 96 | 97 | on_sunrise: 98 | - elevation: 2° 99 | then: 100 | lambda: |- 101 | id(brightness)=1; 102 | on_sunset: 103 | then: 104 | lambda: |- 105 | id(brightness)=3; 106 | display: 107 | - platform: nextion 108 | id: clima_nextion 109 | update_interval: 300ms 110 | lambda: |- 111 | // Do not wait for ACK - it slows down the process, and has no use 112 | it.set_wait_for_ack(false); 113 | 114 | //blocco le scritture temp sul display se non cambia 115 | 116 | if (id(temp_dallas_1).state != id(blocco_temp)){ 117 | it.set_component_text_printf("temp","%.1f",id(temp_dallas_1).state); //Set the sensor's temperature on the display 118 | it.set_component_text_printf("temp_page1","%.1f",id(temp_dallas_1).state); //Set the sensor's temperature on the display 119 | } 120 | id(blocco_temp) = id(temp_dallas_1).state; 121 | 122 | if (id(set_temp) != id(blocco_set)){ 123 | it.set_component_text_printf("setpoint","%.1f",id(set_temperature).state); //Set the sensor's temperature on the display 124 | } 125 | id(blocco_set) = id(set_temp); 126 | 127 | 128 | if (id(hvac_mode).state != id(blocco_stato).state){ 129 | 130 | if (id(hvac_mode).state == "off") { 131 | it.send_command_printf ("b0.picc=1"); 132 | it.send_command_printf ("b1.picc=0"); 133 | it.send_command_printf ("t3.picc=0"); 134 | it.set_component_text_printf("stato","%s","Spento"); //set the state of the heater on the display 135 | } 136 | if (id(hvac_mode).state == "heating"){ 137 | it.send_command_printf ("b0.picc=0"); 138 | it.send_command_printf ("b1.picc=1"); 139 | it.send_command_printf ("t3.picc=1"); 140 | it.set_component_text_printf("stato","%s","Riscaldamenti"); //set the state of the heater on the display 141 | } 142 | if (id(hvac_mode).state == "idle"){ 143 | it.send_command_printf ("b0.picc=0"); 144 | it.send_command_printf ("b1.picc=1"); 145 | it.send_command_printf ("t3.picc=2"); 146 | it.set_component_text_printf("stato","%s","Inattivo"); //set the state of the heater on the display 147 | } 148 | id(blocco_stato).state = id(hvac_mode).state; 149 | } 150 | 151 | if (id(on_off_manual) != id(blocco_manual)) { 152 | if (id(Heating_D3).state) { 153 | it.send_command_printf ("b3.picc=1"); 154 | it.send_command_printf ("b2.picc=0"); 155 | it.set_component_text_printf("stato1","%s","Accesi"); //set the state of the heater on the display 156 | }else{ 157 | it.send_command_printf ("b3.picc=0"); 158 | it.send_command_printf ("b2.picc=1"); 159 | it.set_component_text_printf("stato1","%s","Spenti"); //set the state of the heater on the display 160 | } 161 | id(blocco_manual) = id(on_off_manual); 162 | } 163 | 164 | - platform: nextion 165 | id: nextion_stamp_ora 166 | update_interval: 40s 167 | lambda: |- 168 | auto data_text = id(homeassistant_time).now().strftime("%d-%m-%Y-%H:%M"); 169 | it.set_component_text("data", data_text.c_str()); 170 | auto time_text = id(homeassistant_time).now().strftime("%H:%M"); 171 | it.set_component_text("t0", time_text.c_str()); 172 | 173 | - platform: nextion 174 | id: nextion_brightness 175 | update_interval: 10s 176 | lambda: |- 177 | if (id(brightness) <2){ 178 | it.set_backlight_brightness (100); 179 | } 180 | if (id(brightness) >2){ 181 | it.set_backlight_brightness (10); 182 | } 183 | 184 | - platform: nextion 185 | update_interval: 5s 186 | id: nextion_page 187 | lambda: |- 188 | if (id(nex_page)==11) { 189 | it.goto_page ( "page0"); 190 | id(nex_page) = 10; 191 | } 192 | if (id(nex_page)==9) { 193 | it.goto_page ( "page1"); 194 | id(nex_page) = 8; 195 | } 196 | 197 | 198 | binary_sensor: 199 | - platform: status 200 | name: "ESP TERMOSTATO" 201 | 202 | - platform: nextion 203 | page_id: 0 204 | component_id: 6 205 | id: set_up 206 | name: "set up" 207 | on_release: 208 | lambda: |- 209 | id(set_temp) = id(set_temp) + 0.5; 210 | if (id(set_temp) == 31){ 211 | id(set_temp) = 30.0; 212 | } 213 | 214 | - platform: nextion 215 | page_id: 0 216 | component_id: 7 217 | id: set_down 218 | name: "set down" 219 | on_release: 220 | lambda: |- 221 | id(set_temp) = id(set_temp) - 0.5; 222 | if (id(set_temp) == 14) { 223 | id(set_temp) = 15.0; 224 | } 225 | 226 | - platform: nextion 227 | page_id: 0 228 | component_id: 4 229 | id: heater_off 230 | name: "Turn Heater Off" 231 | 232 | - platform: nextion 233 | page_id: 0 234 | component_id: 5 235 | id: heater_on 236 | name: "Turn Heater On" 237 | 238 | - platform: nextion 239 | page_id: 1 240 | component_id: 2 241 | id: heater_off_local 242 | name: "Turn Heater Off" 243 | on_release: 244 | - then: 245 | - switch.turn_off: Heating_D3 246 | - then: 247 | lambda: |- 248 | id(on_off_manual) = 0; 249 | 250 | - platform: nextion 251 | page_id: 1 252 | component_id: 3 253 | id: heater_on_local 254 | name: "Turn Heater On" 255 | on_release: 256 | - then: 257 | - switch.turn_on: Heating_D3 258 | - then: 259 | lambda: |- 260 | id(on_off_manual) = 1; 261 | 262 | uart: 263 | rx_pin: GPIO3 264 | tx_pin: GPIO2 265 | baud_rate: 9600 266 | 267 | globals: 268 | 269 | - id: set_temp 270 | type: float 271 | initial_value: '15.0' 272 | restore_value: no 273 | - id: nex_page 274 | type: int 275 | initial_value: '11' 276 | restore_value: no 277 | - id: on_off_manual 278 | type: int 279 | initial_value: '0' 280 | restore_value: no 281 | - id: brightness 282 | type: int 283 | initial_value: '0' 284 | restore_value: yes 285 | 286 | - id: blocco_manual 287 | type: int 288 | initial_value: '3' 289 | restore_value: yes 290 | - id: blocco_temp 291 | type: float 292 | initial_value: '0.0' 293 | restore_value: yes 294 | - id: blocco_set 295 | type: float 296 | initial_value: '0.0' 297 | restore_value: yes --------------------------------------------------------------------------------