Is it possible to use a State Variable for a length of time in a condition?

I’m trying to set a variable based on the time of day.

I have a Condition that turns off the backlight LEDs on the mirrors in my master bathroom, if they were automatically turned on by a motion sensor in the wall switch. It works great, but right now, it’s set for 30:00 minutes. Normally, unless I’m taking a really long shower, that’s more than enough time to trigger the motion sensor again, motion to stop, and turn it off after I leave the bathroom (30 minutes later).

cMBathMirrorAutoOn AND ( tMBathMotion ; tMBathNotMotion ) AND ( tMBathNotMotion ; NOW > 30:00)

However, I’d like to change the 30 minutes to a variable that can be set by other conditions or schedules. For instance, it doesn’t make sense to keep the light on for 30 minutes if I get up in the middle of the night to use the toilet and go back to bed. 5 minutes might be a better variable.

I’ve never worked with State Variables before, which I believe would be the way to go. What’s the easiest way to go about doing this?

Thanks for any advice you can provide.

A condition can function as a variable. So you could create a condition “BackLightTime” and put into the condition the logic to calculate a number based on whatever you want. Then cMBathMirrorAutoOn AND ( tMBathMotion ; tMBathNotMotion ) AND ( tMBathNotMotion ; NOW > BackLightTime). Just make sure BackLightTime really/always calculates to a number and not text…

Note schedules can take a value to override their default time setting. So having an action start a timer with a length of time passed to it is another way to do this.

Great suggestion, I didn’t think of it that way. I’ll give that a go!

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules