Trigger action once as power goes above threshold

I migrated from ST to Hubitat this weekend and it's going pretty smooth so far. I've run into an automation I can't figure out using RE 4.

How do I build a rule which only only triggers as the threshold is crossed instead of triggering all the time because the value exceeds the threshold? Should I be using something other than RE like a community app?

We have a smart plug that our entertainment center plugs into. I had a piston in webcore which would trigger when the power consumption exceeded 120 watts to activate a lighting scene. It would only trigger once as the power exceeded the 120 watt threshold. When the consumption dropped back below 50 watts, another piston would bring the lights back up, again only triggering once. We have a button which was setup to brighten / dim the lights for times when we want the entertainment center on, but don't want the lights dim.

If I try to recreate this setup, the lights gets brighter when I press the button, then they dim again a few seconds later because the rule saw the power consumption was above the threshold.

I've tried a pretty convoluted combination of RE 4 rules and button controllers and I still can't get it work right.

Do you care about the zone between 50 and 120? Say If power goes to 125 then back down to 75, and then back to 125, should it trigger twice?

Or do you want his binary? Power above 120 until power is below 50 before a second trigger at 120?

Here is an example of a power monitoring Rule Machine 4 Rule I use to monitor my washing machine. It is similar to your request, but you'll need to tweak the various sections appropriately for your needs. The most important thing to take away from this is the use of RM's Private Boolean feature for each rule. This simple boolean variable is what can be used to prevent the Actions from running more than once.

1 Like

Binary. Once power is above 120, trigger the TV lighting scene. Once it returns below 50, return the lighting to normal.

I had a single crossover point in the past. The problem is there are uses the entertainment center can be in where we don't want the lighting to kick in. In it's idle state, it sits around 30-40 watts with vampire power, wireless gear, etc. Fully functioning, as we would watch a movie, it runs around 160 watts. But, if we just want to have the stereo on, or use the TV as an additional monitor, it sits in that middle range.

So @ogiewon pretty much has it

Trigger:
Power level of Washer changed

Actions:
if (power level >120 and Private Boolean is false)
Set private boolean true
    Set lighting for 120W
else if (Power Level <50 and private boolean is true)
    Set Private boolean false
   Set lighting for 50W)
end if
2 Likes

@napalmcsr, Looks correct to me. Thanks for providing a much better example.

@nshoe74, let us know how your testing goes!

1 Like

Worked like a champ. Thanks @napalmcsr and @ogiewon. This was usually responsive with Smartthings, but it's almost instantaneous now.

2 Likes