There are circumstances where one might want to modify the Expire timeout duration from a rule. For example, maybe a light should stay on longer on weekends or when no one is home.
This rule template will create a Script type rule. It does not have any triggers of it’s own. It is intended to be called from another rule, passing the Item and the duration string as arguments.
parameter | expected value |
---|---|
item |
The Item Object or name of the Item to update the metadata |
newDuration |
A duration string supported by the expire binding. Note, Expire will accept just defining the parts of the duration you are using (e.g. 5s ) but that confuses MainUI so always include all three fields (e.g.0h0m5s ). Using capital letters also confuses MainUI. In both cases they are treated as an error by the rule. |
If newDuration
is null
or not passed, the rule will remove the expire metadata from the Item . Only the duration time is changed. All other parts of the expire metadata remains unchanged.
If the Item does not have expire
metadata, it will be added.
An example in JS Scripting 11 for calling the rule.
rules.runRule('dynamic_expire',
{item:'TestSwitch', newDuration:'0h2m3s'},
true);
Watch the logs for errors.
Language: JS Scripting 11
Dependencies:
- openhab-js 4.1.0+
- openhab_rules_tools 2.0.1+
Changelog
Version 0.2
- throws an exception if the openhab-js or openhab_rules_tools are not the right verisons
Version 0.1
- initial release