Trigger on state change only

OK, sorry about this post, feels like such a simple thing but I’ve not been able to find a way of doing it…

All I want to do is trigger an automation on an entity state change, not an attribute change.

This is what I’ve got but it triggers on every attribute change, which i don’t want.

  - alias: cycle nanoleaf on weather change
    initial_state: true
    trigger:
      platform: state
      entity_id: weather.met_office_moor_allerton
    condition:
      - condition: state
        entity_id: light.nanoleaf_aurora_52_4b_ff_local
        state: 'on'

The only way I can see is to add a condition a bit like;

  condition:
    - condition: template
      value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"

But that seems really clunky, is there a simple way to just trigger on state change, not attribute change???

:slight_smile:
Thank you

3 Likes

The solution you found is the way we all do it.

2 Likes

This showed up in a search for me, but the full functionality has been added to HA since this was discussed.

In the visual editor:

In yaml:

trigger:
  - platform: state
    entity_id:
      - sensor.temperature_30
    from: null
    to: null
3 Likes

The other way that may help if you don’t want unknown states triggering it is:

trigger:
  - platform: state
    entity_id:
      - sensor.temperature_30
    not_to:
      - unknown
      - unavailable