How to wait until the condition isn't met anymore to re-enter the automation


I’ve an automation set that works nicely:

Basically, it sends me a message everytime the outdoor temperature is below the indoor temperature, in order for me to open the windows to refresh the room.

It works perfectly, but it sends me a message every 5minutes, which is not ideal. Is there a way to wait that the condition isn’t met anymore to be allowed to re-enter?

Here is my current template:

alias: Alert open windows
description: ''
  - platform: time_pattern
    minutes: /5
  - condition: template
    value_template: >-
      {{ ( states('sensor.netatmo_givihome_salon_balcon_temperature') | float )
      < (states('sensor.netatmo_givihome_salon_temperature') | float) }}
  - device_id: d7478c53e925f19ccf1eafaaea192d3c
    domain: mobile_app
    type: notify
    message: >-
      Alert! The external
      is below the internal
      Activate the canicule plan(well, open the windows)
    title: Open window
mode: single

Swap it around, i.e. trigger when the temp differs and add a condition to do this between (say) sunrise/set

Thanks for the answer! I’m not sure which other condition I could map? Because depending on the meteo, it may happens at very different times of the day, and even if I say this should only happen between sunrise and sunset, it will still triggers every 5 min

If you make the trigger respond to the temp diff, it will only do it then, remove the 5 mins check is what I meant

Thats because you have set the trigger to be every 5 mins, so if the following condition is true you will get a message every 5 mins just like you have asked for!

If you only want the message once when the condition transitions to true the simply use the condition as the trigger like this:

  - platform: template
    value_template: |-
      {{ ( states('sensor.netatmo_givihome_salon_balcon_temperature') | float )
            < (states('sensor.netatmo_givihome_salon_temperature') | float) }}

Can we have a trigger on a difference on two different sensors? I mean both temperature changes could trigger the issue

Let me try. I did it like this because on another question, it was recommended to proceed like this.

OK, let me know how you get on as I can see any logic in firing an automation every 5 mins, 24 hours a day, 7 days a week for a simple temp automation.

You wrote

So it is always the combination of the two but it is only triggering when the comparison is met.

@rossk :+1:

It will only ever be true or false, so individual state updates will only affect this if it causes it to be true or not true.

Me neither, I taught it was because you could not have more than one sensor as trigger. As of now, it doesn’t trigger the message at regular interval, I’ve to wait tomorrow to see if it still notify.

You can test this by changing the state of one of the temp sensors via Dev tools > States

Thanks, I tested to set the external temperature to 20°, but it didn’t trigger any notification. I see that it went to the real temperature just a moment after it was set to 20°. Any idea why it didn’t trigger?

What was the temp of the other sensor at the time and paste you current/new automation setup again, not sure anymore where you are after all these comments

I’m so sorry, actually I rebooted my phone just before the test, and the phone wasn’t unlocked yet. It’s all working thank you

1 Like