How can I make this RL rule work the way I want it to?

This is the rule I have setup. It uses time periods so the light comes on at 100% during the day, 30% at night, and not at all if we're sleeping.

The problem I have has to do with the variable that prevents the light from turning off if I am working from home. I have a separate rule that sets it to true if the plug reports > 100W and false when it drops below.

Here is the log for the rule that set the variable to False after I put my computer to sleep.

The plug is a Kasa HS110 connected via wifi. It is polled every 5 minutes. So when it polled at 8:35 the power was 123W. When it polled again at 8:40 the power was 22W. So the computer was turned off sometime between 8:35 and 8:40.

Here is the log for the RL instance above during the same time period.

If I turn off the computer and walk out of the room, the light will not turn off until someone walks in and then leaves again. When the variable becomes false and turning off is re-enabled, I want it to check the means to turn off and see if there has been no motion for 2 minutes.

I may have worked around the issue... I'll need to test it out in real world conditions to know for sure.

I added the variable becoming false as a method to turn off the light, but then added an additional restriction that the light can't turn off if motion is active.

My first thought was maybe to add a virtual switch that is tied to your rule to change the variable. Set the virtual switch as another turn off option. The switch comes on when the work from home is on and turns off >= 2 minutes after the variable or if motion is detected.

I think your method will work though.

Turns out this didn't actually work.

It tries to turn off because the variable turns false, but can't because off is disabled. It then immediately enables off, but it's to late.

I suspect the thread that listens for trigger events has a higher priority than ones listening for other events. Or something like that anyway. Makes sense to me.

I looked around at the triggers in RL and there isn't a way to say "variable becomes false for X time" so I think I'll have to use a virtual switch like what you say.

I personally really dislike having to create devices that function as a condition in a rule. My devices list just keeps getting bigger and bigger and naming the devices so I know what they all are can become a pain. I'd love a completely different area to put them in, sorta like how hub variables are separated out; and I don't just mean separating virtual from physical devices, because I have a lot of virtual devices that represent a physical thing.

Or even if the backend could be made so that a hub variable is more like a device. For example, a bool just represents a binary state, just like on/off or open/close or present/departed. Would be pretty cool if I could just use my hub variable as if it were a virtual switch.

What if you tried adding a delay to turn off the lights? That’s an option in the Turn off the lights section. Add a 5 second delay to the turn off command. That would give your variable a chance to reactivate the off command and potentially serve as the means to turn off.

Was a good thought, but it seems to not have made a difference. I added a 5 second delay, but it looks like the check to see if the restrictions are still true happens before the delay and not after. The log looks the same as the post above, so no need to post a new screenshot.

That's unfortunate. Looks like you have one of two ways:

1.) Create an Activator Device and then have a rule to turn off the activator device when the variable becomes false.
2.) Could you create a rule that ties the variable to the Office - Light switch? That could work depending on how you use the switch in other scenarios and would prevent the need to create a new virtual device.

Download the Hubitat app