How to avoid repetition in automation?

Hello,

I made an automation for the weather alert (in France) to notify me when it’s necessary.
But, the state is update every 6h, and HA notify me for the same thing.
Do you know how can I avoid this repetition ?

- alias: Weather alert
  trigger:
    platform: state
    entity_id: sensor.city_weather_alert
  action:
    service: notify.mobile_app_galaxy_s8
    data:
      title: Alerte
      message: Alerte Météo {{ states('sensor.city_weather_alert') }}

Your automation as written will trigger anytime sensor.city_weather_alert changes, for whatever reason even if it’s just the attributes changing and not the state. You are missing some sort of condition to only notify you “when it’s necessary”. Either 1) set the trigger to notify for only the specific states you want, or b) use a condition to prevent unwanted alerts from sending the notification.


You right, but I don’t find the good solution, because the possibilities are Green or Orange or red and I would like to know when the state changing, in every way (Green to Orange or Red, but Orange or Red to green too).
If I use in the trigger From or To, it’s not good.

You can have a) multiple triggers, or b) you can use a template trigger to consider more complex states.

For #a, you just list the different combinations of from and to. For #b you can write some template code to return True only for the cases you want. If you are using the UI to create automations, it’s very simple to add multiple triggers.

Hello,
This is my solution for the moment, and it’s seem work well :

- alias: Weather alert
  trigger:
    - platform: state
      entity_id: sensor.city_weather_alert
      from: "Green"
    - platform: state
      entity_id: sensor.city_weather_alert
      from: "Yellow"
    - platform: state
      entity_id: sensor.city_weather_alert
      from: "Orange"
    - platform: state
      entity_id: sensor.city_weather_alert
      from: "Red"
  action:...
1 Like

I have a other case for my problem. I want to avoid a repetition an I explain to you :
When I want to turn on my light when I open my door, but I don’t want to trigger again when I open my door again . This is my current automation. Can I block my trigger during some minutes ?
Could I have some help ?

- alias: Light on
  trigger:
    platform: state
    entity_id: binary_sensor.entry_door
    to: "on"
  condition: