Help needed for a rule to notify me when a switch has had a certain wattage usage for a certain time

Hello!
Iā€™m trying to get Hubitat to notify me when my projector has been left on. Basically, Iā€™m trying to make a rule where if a certain outlet/switch has had over 20w of power running through it for 4 hours I get a notification. Obviously, if the power drops to zero before the 4th hour is reached (my lovely wife remembers to turn off the projector), I want the notification to be cancelled (this latter part is where Iā€™m struggling).

Thank you!

The classic "IF/ELSE" paradigm in Rule Machine would handle this well, I think. I'm using Private Boolean as well to track whether the power went over 20 W already since we only care about this the first time around, but there are other ways to handle that if you already had something in mind:

Trigger Events: Projector power *changed*

Actions to Run:

IF (Projector Power > 20) THEN
  IF (Private Boolean is FALSE) THEN
    Set Private Boolean True
    Delay 4:00:00 (cancelable)
    Send notification: "Projector on for 4 hr!"
  END-IF
ELSE
  Set Private Boolean False
  Cancel Delayed Actions
END-IF

Alternatively, as long as you start with the projector off after creating the rule, then this rule is a bit simpler and should have the same effect (I know it seems a bit odd triggering on less than 20 W, but that serves as a way to cancel the wait and creates a subscription in the actions for the >20 W event that ultimately does what you want if that also doesn't get cancelled due to lower usage in the meantime):

Trigger Events: Projector power < 20 W

Actions to Run:

Cancel Delayed Actions
Wait for event: Projector power > 20 W
Delay 4:00:00 (cancelable)
Notify "Projector on for 4 hr!"
1 Like

Genius - thank you so much for the response, this should work beautifully!

Our sump pump is plugged into an Iris smart outlet. (3210-L). Here's what I'm using for notification that the sump pump is active:

Trigger event:
  Power level of RP5 Zigbee Outlet (sump pump) *changed*

Select Actions for Sump Pump Notification
IF (Power level of RP5 Zigbee Outlet (sump pump)(0) is > 500.0(F)  AND 
Private Boolean is false(T) [FALSE]) THEN
	Notify Phones via Twilio  and Speak on speakers(volume: 75): 'Sump pump active at %time% %date%'
	Flash: Lighting Master Group
	Set Private Boolean True
END-IF
IF (Power level of RP5 Zigbee Outlet (sump pump)(0) is < 100.0(T)  AND 
Private Boolean is true(F) [FALSE]) THEN
	Notify Phones via Twilio and Speak on speakers(volume: 75): 'Sump pump is off at %time% %date%'
	Set Private Boolean False
END-IF
1 Like