I am curious to ask wheter it is possible to “pause” the expire flag for a certain time.
So sometimes it is necessary to be in a room longer than the normal “expiry time” because you need to do some craftsman things or if you clean the room up for a longer time. And then you do not want to turn on the light every 3 minutes or something like that. And for my wife it is not possible to change the expire time herself before doing the things or when I am not at home.
As I do not want to buy presence sensors for all rooms where I use the expire flags I want to know if there is any possibility to pause it (as long as a specific switch item is ON or something similar) without a change in the code to remove the expire flags.
- Platform information:
- openHAB version: openHAB 3.1.0.M3
For more flexible timing, you must used rules-based timers.
The title had me confused. OH3 does not have an expire binding. It is part of the core now.
would it be possible to send the ON command every minute to keep the light on and reset the start time of the expire value or is this not possible?
As a thought, you can manipulate the metadata that controls the expire functionality from within a rule. For example:
var OPENHAB_CONF = Java.type("java.lang.System").getenv("OPENHAB_CONF");
var metadata = get_value('TestSwitch', 'expire');
//is currently set to 5s
set_value('TestSwitch', 'expire', '0h0m20s,command=OFF');
//now set to 20s
I tested this and observed that if the switch is ON when the rule runs the expire won’t happen. Once the switch is toggled it will though, using the new timing that was defined.
Using this method to remove the expire metadata, then readding it when the control is deactivated may just work. If you want to make sure the expire takes effect after it’s put back in place (say the light is still on) you can do this:
Sure. By the time you’ve set up a time-controlled rule to do that, you might just as well use a ‘proper’ timer to begin with.