Automation trigger - when "count" changes

OK, I am building a notification automation which should be triggered under these, specific conditions:

I have a sensor for a message-provider (german weather service)…
The default state is 0 - no warnings, no severity level

A notification should be triggered, when the severity level (state) changes to 1…
This is working so far - simple logic.

Now, another notification should be triggered, when the severity level (state) changes to 2 …
And so on.
It should NOT be triggered when the state changes back from 2 to 1 or from 1 to 0 or even from 2 to 0 …

It should be valid for all “possible” severity levels… so I would go from everything from one - up to 5 or 7 maybe (don’t know, how many levels there are)

Can this be done directly in the automation, or do I need to create some custom triggers ?

  - trigger:
      - platform: state
        entity_id:
        - sensor.dwd_current_active_warnings
          [CONDITIONAL SETTINGS]

If you want a trigger on an increase but not decrease you could do this:

  - trigger:
      - platform: state
        entity_id: sensor.dwd_current_active_warnings
        to: 
    condition:
      condition: template
      value_template: "{{ trigger.to_state.state|int(0) - trigger.from_state.state|int(0) > 0 }}"
    action:
      - ...
1 Like

thanks.
Despite a failed rendering of the message (due to missing attributes) I think, that should work now :slight_smile:
I will observe this further more.