Send state to HA only at change

Is it possible that ESPHome module would send some state to HA only when this state changes, or only manually?
Specific example: dimmer: I would like to see dimmer value in HA in real-time, so that state change is immediately seen. For this one option is to set dimm value sending to HA every second, which is, i guess, pretty hard for HA installation (or not?).

  - platform: template
    name: "Dimmer value"
    id: "dim_value"
    update_interval: 1s
    accuracy_decimals: 0
    lambda: |-
      return (int(id(light_dimmer).remote_values.get_brightness() * 100));

So,

  • is sending state every second ok or not (i did exclude this entity from recorder)?
  • is it possible that dimmer value would be sent only when this value changes? So when, say, i trigger “switch.set_dimmer_to_20” would set dimmer to 20% and at the same time send new value to HA instead of above template?

Have you tried the delta filter?

https://esphome.io/components/sensor/index.html#delta

1 Like

YES!!! Many thanks! Of course it works! I just added:

filters:
  delta: 1

and my sensor sends state only when i change dimm value!

Many thanks again!

1 Like