Pause expire binding

Hi everyone,
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

No.
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");
load(OPENHAB_CONF+'/automation/lib/javascript/core/metadata.js');

var metadata = get_value('TestSwitch', 'expire');

logger.info(metadata);
//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:

events.postUpdate('TestSwitch', items['TestSwitch']);

All samples above were tested with 3.0.1, using UI defined Javascript rules. The metadata.js file referenced is a slightly modified version of the one released some time ago for OH2 in the openhabscripters repo.

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.

1 Like