I am not sure if this is persistence category, but I can think that may be one way to approach.
What I like to do is fairly simple.
When garage door is open for 1 hour, announce that to my Sonos speakers. Specially, I am using MyQ binding.
My version of OpenHAB3 is Milestone.
I can’t seem to find option in OpenHAB 3 Rule UI. Logically, what I need to use is persistent information.
What is the correct way of doing this in OpenHAB 3?
Thank you,
rossko57
(Rossko57)
May 5, 2021, 11:54pm
2
Not really. You want something to happen after a time. Persistence doesn’t make anything happen, it just offers a look-up into the past.
You could keep looking to see if something happened an hour ago, but that’s a lot of pointless look-see.
Generally in openHABs event driven rule system, use a Timer for jobs like this.
Recent post using javascript rule
Thank you @rossko57 !
Rescheduling the timer was a great hint! This also makes the code a lot less complex:
var NotificationAction = Java.type("org.openhab.io.openhabcloud.NotificationAction");
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");
var ZonedDateTime = Java.type("java.time.ZonedDateTime");
var ChronoUnit = Java.type("java.time.temporal.ChronoUnit");
// Reset timer when handle is used
if (this.timer != undefined) {
this.timer.cancel();
this…
general guidance
There is now a rule template in the marketplace that implements this. See below for instructions on how to set it up for this DP.
Please see Design Pattern: What is a Design Pattern and How Do I Use Them for details on how to use DPs.
Problem Statement
Many motion detectors only report ON when they detect motion but do not send a corresponding OFF after no motion has been detected after a period of time. In addition, often one wants to control a device like a light for a certain period after …
You will have to write script in a rule to use timers, it goes beyond the point-n-click capability.
1 Like
Good to know. Thank you for the links.