Hi All,
I’m a newcomer into the OpenHab community, I feel greate because I have made big progresses in my understanding of the key concepts of the 3.0 version but I got stuck with a very basic step creating my first automation rule… I dont know how to add a delay (timer) in between 2 actions.
The automation I’m trying to create is as follows:
Trigger = When an input phrase from Alexa is detected 2 actions should be triggered:
Action 1 = TurnOn a TV
Action 2 = Switch to Netflix
The Rule works well if the TV is already ON (Action 1 is executed but no changes because is already ON and Action 2 is executed successfully because it switch to Netflix)
The Rule Fails if the TV is OFF (Action 1 is executed correctly and TV turns ON but Action 2 fails because it is sent immediately after Action 1 is triggered and TV is still not ready to receive the command, consequently the action is executed but not “heard” by the TV)
I assume that adding a 5 Secs delay between Action 1 and Action 2 will solve the problem… but I cant find how to add this delay.
Seems like using a timer will solve it but I dont know how or where to code it, I will really appreciate if you can help me to solve this issue.
Please remember I’m using OH3 which I think to understand is using the Next Generation Rule Engine.
NOTE: You may see many warnings against using Thread sleep in posts on the forum. Those are referencing older versions of OH, not OH 3. They are not that much of a problem in OH 3.
Hello again Rich,
Sorry I have to bother you again but I was trying to make the script work and Icant.
In JavaScrpti the TV ON/OFF and the sleep command works well, but the Application Change command to Netflix dosent. I been trying all possible combinations before posting again and I couldnt make it work. Added other options like Mute, Volume, etc and all work, but the Application Change dosent. Application Change works from the toggle in the Item.
The script in Rules DSL dosent work at all for me.
Im attaching some screenshots of the scripts and the Item and thing configurations.
I’m doing something wrong?
Thanks,
Pablo
Many thanks @rlkoshak this is usefull also in my case.
I made this rule for delay on off a light, I need the contact work like a botton instead of switch :