Help pausing a rule that sends notifications

I have the following rule named AQI>65 that sends a notification to my phone when my air quality monitor reports a value > 65.

Needless to say air quality might remain above 65 for long periods of time, so I am trying to pause rule AQI>65 for 2 hours after it is triggered, so that at most I receive one notification every 2 hours. I created rule AQI>65 PAUSE to try to accomplish this:

This works correctly IF air quality remains > 65 for 2 hours or less at a time. But after 2 hours, I start getting notifications every few minutes, presumably because rule AQI>65 PAUSE is getting repeatedly triggered over and over again and after 2 hours there are repeated "resume" actions being triggered.

At the end of my day, I don't really care how I do it, but I only want the rule AQI>65 to be able to send a maximum of 1 notification every 2 hours.

Any advice on the simplest way to accomplish that?

You may want to look at doing this with the built-in Notifications App. That app has options for how often to repeat the notification when a condition remains. It seems like it might work for your application . . .

Thanks for the suggestion. I looked into that but the "aqi" value from my PurpleAir is a "custom attribute" that I have access to from Rule Machine, but the built-in Notifications app does not have a "custom attributes" option so I cannot choose the "aqi" value as the trigger for a notification, as far as I can see.

How often does the value change?

Off the top of my head, you could...

You can expand with local variables to enhance some information.
If this is a value that updates frequently, this rule will execute frequently -- a Required expression might help limit some of that.

Bummer!

Might consider setting a date/time variable for 2 hours in the future each time you send a notification, and not send another until the current date/time is > than the variable.

The purpleair AQI value gets updated every 5 minutes I believe (might even be every 1 or 2 minutes).

I see in your example it is listed as "temperature." That actually gives me an idea. Do you know if it's possible to change PurpleAir's custom attribute "aqi" so that Hubitat sees it as a temperature? If I could just make hubitat see it as a "temperature" rather than as a custom attribute, then I could try using the built-in "Notifications" app...

could use a virtual switch to turn on when the aqi is >65, and then have the notifier app go based on that VS turning on

yes i would use a virtual switch and have your notify rule have a required expression switch must be off.
have a rule that sets the switch on when aqi >65 and stays that way for a time ie 2 hours.

then have another or the same rule turn it off when it goes below 65 ..

you may want a stays that way also for a time so you dont get ping ponging when it jumps around over and under 65 repeatedly in a short time.

I would use a device that has been configured as a "switch timer", to turn ON after 2 hours, and use that device in the rule.
(with reset capability).

Here's how I would setup the rule

Required Expression:
PurpleAir aqi < 65.0

Trigger Events:
PurpleAir reports aqi >= 65.0

Actions to Run:
Repeat every 2:00:00 (stoppable)
    Notify SM-S911U1: 'AQI>65'
    Wait for event: PurpleAir reports aqi < 64.0
    Stop Repeating Actions
END-REP

The 64 aqi in the Wait is just pointing out that you should probably incorporate some sort of deadband.

Huge thanks to everybody for the replies and ideas.

I ended up creating two separate rules: AQI>65 PAUSE and AQI>65 RESUME.

I was afraid it might have the same problem when AQI is greater than 65 for several hours straight, but we had bad air quality last night and this solution actually appears to have worked:

Thanks again for the helpful input. I'm still planning to test out some of the suggestions in this thread at some point just to get a better understanding of how all of this operates. I especially liked the virtual switch idea.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.