Hi,
i need some help with a Rule for a Xiaomi Motion Sensor.
I want to check every 30 Minutes if lastmotion on the Motion Sensor is older than 15 Minutes and then shut off the light.
I have no idea how to do this. Can someone help`
BR
Karsten
Hi,
i need some help with a Rule for a Xiaomi Motion Sensor.
I want to check every 30 Minutes if lastmotion on the Motion Sensor is older than 15 Minutes and then shut off the light.
I have no idea how to do this. Can someone help`
BR
Karsten
Hi Karsten,
I was looking for the same thing. I think I will try this one with node red, but then without the light intensity.
https://www.linkedin.com/pulse/node-red-smart-home-making-your-first-rule-tutorial-artyom-syomushkin
But if it is possible to put this in a rule that would be nice.
BG
Martijn
Hi Rich,
that didn´t help me. i have the Motion Sensors already running. The have a DateTime State where there seen the last Motion. I want to create a Cron Rule that checks every 30 Minutes if the LastMotion is older than 15 Minutes and if yes switch off the Light.
Why not set a timer to turn off the light 30 minutes after the last motion without polling?
As a general rule, if you are polling, you are probably doing it wrong and there is almost always a better way.
The DP describes a better way. Then there is no need for the DateTime Item or a Rule to poll. Just one Rule to trigger when motion is detected and one Rule to run when motion wasn’t detected for 30 minutes (assuming you use the Expire binding example in the DP).
This is what I use. Works with every sensor.
rule "Kitchen Motion Sensor ON"
when
Item EG_kue_motion_presence changed from OFF to ON
then
if (EG_kue_motion_illuminance.state > 12){ //18 zuvor
return;}
if(timerKue === null || timerKue.hasTerminated) {
timerKue = null
EG_kue_li_decke.sendCommand(ON)
logInfo("Motion KĂĽche", "Bewegung erkannt -> Licht an")
}
else {
timerKue.cancel
timerKue = null
logInfo("Motion Küche", "Bewegung erkannt -> Timer gelöscht")
}
end
rule "Kitchen Motion Sensor OFF"
when
Item EG_kue_motion_presence changed from ON to OFF
then
if (EG_kue_li_decke.state == OFF){
return;} //false bevor
logInfo("Motion KĂĽche", "Keine Bewegung mehr erkannt -> Timer gestartet")
timerKue = createTimer(now.plusSeconds(120), [ |
timerKue.cancel
timerKue = null
EG_kue_li_decke.sendCommand(OFF)
logInfo("Motion KĂĽche", "Timer abgelaufen -> Licht aus")
])
end
Credits to the forum, where I found the original code, which I modified for my needs.
The Problem is, that the Xiaomi Sensor give the State: true or false. Not ON or OFF.
Is there anyone with a hint to solve this Problem? I tried wit the xiaomi.js. I can see now “Ruhe” or “Bewegung” in my sitemap. But i can not work with it in rules.
Show us your Item type and your events.log showing state changes.
Not sure, how you connected your sensor.
I connected mine with zigbee2mqtt, which works like charm.
If you do as well, I recommend you this post: Zigbee2mqtt revisited: No more ugly transformations
You get rid of the transformation files, which makes the life much easier. There is also the correct setup for the motion sensors listed.
THX so much!!! it works!
Works perfect for me. Thanck you.