I’m designing a wall-mounted controller based on esphome (buttons + LED display), to controll climate, lights, shutter etc.
I’m using “platform: homeassistant” sensor to get and display the climate setpoint temperature and it works OK:
- platform: homeassistant
id: setpoint_temperature
entity_id: ${target_climate_name}
attribute: temperature
internal: False
But when I change it in ESPHome and publish new state, it does not change the attribute value in Home Assistant (but it changes it in ESPHome properly)
- platform: gpio
name: "${dev_name} DOWN button"
pin:
number: GPIO13
inverted: true
mode:
input: true
pullup: true
filters:
- delayed_off: 30ms
on_press:
then:
- lambda: id(setpoint_temperature).publish_state(id(setpoint_temperature).state - 0.5);
- component.update: my_display
Is this by design, or am I missing something?
Right now I’m using workarount calling homeassistant.service to change setpoint:
# DOWN button
- platform: gpio
name: "${dev_name} DOWN button"
pin:
number: GPIO13
inverted: true
mode:
input: true
pullup: true
filters:
- delayed_off: 30ms
on_press:
then:
- lambda: id(setpoint_temperature).publish_state(id(setpoint_temperature).state - 0.5);
- homeassistant.service:
service: climate.set_temperature
data:
temperature: !lambda "return id(setpoint_temperature).state;"
entity_id: ${target_climate_name}
- component.update: my_display
It works, but not very comfortable - when button is pressed several times, often it “refreshes” the previous value from homeassistant during the series of press, returning value to the state before few clicks.
So, if there is anyone who have experience with that and can share what is the best method of getting and controlling attribute of entity from Home Assistant, I’ll appreciate that.