Hello everyone,
I hope I am posting at the right place… This is my first post!
after searching for houres, and not finding any helpful posts, i would like to share my problem with the community.
I am trying to set up a custome thermostate, using a nodumcu (through ESPHome) a Nextion display and a Generic Thermostat from Home Assistant.
The plan is the following:
- display the current temperature, humidity, and target temperature to the Nextion Display
- display the current temperature, humidity, and target temperature to the thermostate card in lovelace
- “conect” the target temperature of nextion display and thermostat card, so when changing the target temperature from the display, the lovelace card is being change as well and vice versa.
So far, 1 and 2 are working fine, but I am having difficulties on number 3.
Following are the YAML files of the ESPHome and the Home Assistant configuration
ESPHome YAML:
esphome:
name: esp2
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "***"
password: "****"
manual_ip:
static_ip: 192.168.1.113
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
dns2: 192.168.1.1
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "****"
password: "****"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
- platform: dht
pin: D3
model: dht11
temperature:
name: "Thermostat Temperature"
id: therm_temp
humidity:
name: "Thermostat Humidity"
id: therm_hum
update_interval: 30s
- platform: homeassistant
id: temperature_thermostat
entity_id: sensor.thermostat_temperature
- platform: homeassistant
id: humidity_thermostat
entity_id: sensor.thermostate_humidity
- platform: template
name: "Set Temperature"
lambda: |-
return {id(set_temp)};
update_interval: 1s
switch:
- platform: gpio
name: "Heater"
id: heater
pin: D5
inverted: yes
binary_sensor:
- platform: gpio
pin:
number: D7
mode: INPUT_PULLUP
inverted: yes
id: 'bouton_heater'
name: "Bouton Heater"
on_state:
then:
- switch.toggle: heater
- platform: nextion
page_id: 0
component_id: 6
id: minus_set_temp
name: "Minus Set Temperature"
on_press:
lambda: |-
id(set_temp) = id(set_temp) - 1;
if (id(set_temp) == 14){
id(set_temp) = 15;
}
- platform: nextion
page_id: 0
component_id: 5
id: plus_set_temp
name: "Plus Set Temperature"
on_press:
lambda: |-
id(set_temp) = id(set_temp) + 1;
if (id(set_temp) == 36){
id(set_temp) = 35;
}
i2c:
display:
- platform: nextion
id: teplomer
update_interval: 1s
lambda: |-
// Do not wait for ack (this delays the whole procedure a lot, and has no use)
it.set_wait_for_ack(false);
it.set_component_text_printf("temperature","%2.1f",id(therm_temp).state);
it.set_component_text_printf("humidity","%2.1f",id(therm_hum).state);
it.send_command_printf("n0.val=%d",id(set_temp));
it.send_command_printf("n1.val=%d",id(set_temp));
uart:
rx_pin: GPIO1
tx_pin: GPIO3
baud_rate: 9600
globals:
- id: set_temp
type: int
initial_value: '15'
restore_value: no
configuration YAML: (only what is relevant)
climate:
- platform: generic_thermostat
name: Heater
heater: switch.heater
target_sensor: sensor.thermostat_temperature
min_temp: 15
So the question is, what do I have to do, in order to connect “set_temp” from the ESPHome YAML (the dispay variable) with the thermostat target temperature, so when I change, the other changes as well.
In the configuration YAML I also tryied to do this:
set_temp: '{{ ((states(''sensor.set_temperature_2'') }}'
but it does not convert to float, so no luck theire!
Any help will be much appreciate!!
Thank you in advance.