Only run automation once until something changes?

Hi guys! A while back I created a simple automation to notify me when our pool spa reaches the set heat temperature. It works fine, the only issue is the temperature can fluctuate slightly which causes it to continuously notify me every time that happens. Ideally what I want is for it to intially notify me, and then not again unless either the heater/pump is turned off/back on or the target temperature is changed. I tried using a wait_for_trigger but it doesn’t seem to have made a difference. I know I could use a helper and create a second automation to change the boolean but i’d rather simplify it and keep it all in one automation which I believe can be done, just not sure the most efficient way. TIA!

You could create a threshold helper based on the pool temperature, then trigger the automation from that. A threshold helper allows you to define a hysteresis - a zone on either side of the target temperature - where the on/off value of the helper does not change. It’s designed to prevent exactly the sort of “wobble” you describe.

An alternative is to use a toggle helper as an override - turn it on when the target temperature is reached and have a condition preventing the automation from running until it is turned off again.

Edit:

There’s really no benefit to keeping everything in one automation - they all go in the same yaml file. All the ifs and buts you need to make it work often make it longer and more difficult to maintain than two (or more) separate automations.

1 Like

could add a wait / delay after the automation is triggered, hopefully then only giving you the initial response with a delay long enough to not be annoyed with alerts

action:
  - service: notify.mobile_app_iphone
    data:
      message: PH is high!
  - delay:
      hours: 6
      minutes: 0
      seconds: 0
      milliseconds: 0
mode: single