Hi,
I have a Xiaomi Aqara Wall Switch with two channels for opening and closing a skylight window. The problem is that it doesn’t turn off by itself and I would like to know if it’s possible to setup a timer in a rule for each time that it’s on. Something like turn on and after 7 seconds turn off. I tried the rule that I post below but I have an error. Thank you very much!
Platform information:
Hardware: Raspberry PI 3B
OS: openHABian v1.4.1
Java Runtime Environment: openjdk version “1.8.0_152”
OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8 .0_152-b76)
OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, m ixed mode, Evaluation)
openHAB version: openHAB 2
Issue of the topic: Timer in rule error
Items configuration related to the issue
// Llave apertura claraboya baño principal
Sitemap configuration related to the issue
Group item=FF_MotorClaraboyaBanoPrincipal
{
Frame label=“Subir”
Switch item=LlaveAperturaClaraboyaBaOPrincipal_Button1
Frame label=“Bajar”
Switch item=LlaveAperturaClaraboyaBaOPrincipal_Button2
Rules code related to the issue
var Timer timer = null
rule “Tiempo apertura claraboya - Abrir”
when
Item LlaveAperturaClaraboyaBaOPrincipal_Button1 changed to ON
then
timer = createTimer(now.plusSeconds(5) [|
sendCommand(LlaveAperturaClaraboyaBaOPrincipal_Button1, OFF)
timer = null // reset the timer
])
end
If logs where generated please post these here using code fences:
[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Tiempo apertura claraboya - Abrir’: An error occurred during the script execution: index=1, size=1
After install the binding EXPIRE works. I didn’t know this binding. It works perfectly. By the way, thank you very much for everything and I will follow your advice and next time I will use them (code fences - csv.......)
Also, use the .sendCommand method instead of the sendCommand() action
You were missing a comma in your timer syntax
rule “Tiempo apertura claraboya - Abrir”
when
Item LlaveAperturaClaraboyaBaOPrincipal_Button1 changed to ON
then
createTimer(now.plusSeconds(5), [ |
LlaveAperturaClaraboyaBaOPrincipal_Button1.sendCommand(OFF)
timer = null // reset the timer
])
end