Use to_state and from_state in the new trigger condition

Add the ability to use action condition trigger on state change.
Example of current method…

choose:
  - conditions:
      - condition: template
        value_template: '{{trigger.to_state.state == ''on''}}'

New preposed method…

choose:
  - conditions:
      - condition: trigger
        to_state: on

Interesting request but it’s not too difficult to do now, using your first example, or in shorthand notation:

choose:
  - conditions: "{{trigger.to_state.state == 'on'}}"

If I specifically want from off to on, it’s simply this in shorthand notation:

choose:
  - conditions:
      - "{{trigger.from_state.state == 'off'}}"
      - "{{trigger.to_state.state == 'on'}}"

If the automation already has a trigger that listens for the “from off to on” state-change, and it’s the first of several triggers, then we can use trigger.id.

choose:
  - conditions: "{{trigger.id == '0'}}"
2 Likes

Indeed, I just use a lot of these and figured I’d throw it up there now that we have the “trigger” item available in the GUI.