I was wondering if someone could help me as for weeks I’ve been struggling with creating a reliable rule that works. It works most of the time but is not reliable enough to use to replace a light switch.
I’m trying to create a rule so my light switches on when motion is detected then turns off after a set amount of no activity. Also everytime motion is detected I would like the countdown timer to reset and start counting down again. Once set correctly the light should never go off if someone is in the room.
I have tried lots of different variations of the rule below without success. It kind of works but if for instance I set the timer for 1 min then dance in front of the sensor for 10 min it the lights go off on occasion and in some instances it takes at least a minute for the light to come back on again.
Hardware:
Raspberry Pi 3
Razberry 2
Aeotec multisensor 6
Bindings
Z-wave
Expire
What I’ve tried:
I’ve tried a couple of different motion sensors and the Aeotec on works best as that is plugged in via USB.
I’ve set parameter: 3: Motion sensor reset timeout: to 15 seconds 4: Motion sensor sensitivity: Maximum 5: Motion sensor triggered command: Send Binary Report CC
Thoughts/Questions
Is the expire binding capable of reseting once a command is sent again? It appears it does kind of work…
Should I even use expire or should I just add a timer to my rule or something?
Is my rule OK?
Any help/guidance would be much appreciated thanks everyone!
rule "Sensor motion turns on proxy"
when
Item Swi_MSensor_Motion changed from OFF to ON
then
Swi_MSensor_Motion_Proxy.sendCommand(ON)
end
rule "Sensor proxy turns on light"
when
Item Swi_MSensor_Motion_Proxy changed from OFF to ON
then
Swi_Light.sendCommand(ON)
end
rule "Proxy expires light"
when
Item Swi_MSensor_Motion_Proxy received command OFF
then
if (Swi_Light.state == ON)
{
Swi_Light.sendCommand(OFF)
}
/*
if (Swi_Light.state > 0)
{
Swi_Light.sendCommand(0)
}
*/
end
In my understanding:
PIR Motion detected
Switch Swi_MSensor_Motion goes to ON
Motion detect time end (15sec.)
Switch Swi_MSensor_Motion goes to OFF
This is the case for my philio PIRs. They are working perfect.
The AEOTEC does not have this behaviour in any case. Sometimes yes, soemtimes no. I tried to override the not reset status OFF with expire binding. But this does not fix it at all. in 50% of the cases a retrigger of PIR is does not change status of switch to ON.
For me it looks like the aeorec implementation is not the best.
I agree that the sensor could be temperamental at times but this is as is expected with any wireless device. However even when I set my expire at 10 minutes it is still not reliable. Therefore even if it does not detect motion all of the time I should still be OK.
For example, if I set the expire to 10 minutes then dance in front of it, the Aeotec sensor will have 40 opportunities to reset the timer back to 30 minutes (with 15 second parameter set) so the light should never go off in this time. That is not the case though.
I wonder if someone could let me know if my rule is as it should be or if there is a better way to achieve what I’m after?
I have that working a couple of places. I know I have your first 2 rules combined into one. I cannot check right now but I seem to remember a command to reset the proxy?
I have also this multisensor 6 but not really troubles.
The sensor is not the fastest but is okay for me so far.
I guess you have the wrong parameter, “detect time end” is the time how long the sensor will ignore motion.
There is another parameter where you can set the time until it will send an “OFF” signal.
So in my rule no need for expiry or anything else, just a simple “ON” (depending on luminosity) and “OFF”.
If you could post your working rule here when you get chance that would be really helpful thanks as I can test
@Bruce_Osborne is correct, I don’t do anything with the off command of the sensor as my proxy does that for me. When the sensor sends the ON command that is the only trigger I require. With parameter 3 set to 15 sec it should send the ON command every 15 seconds if I’m constantly moving in front of it. Or at least that is what I assume.
I have altered this ruleto suit my home using Hue lights Aeotec MultiSensor 6 (with default settings) and have absolutely no issues with motion detection for lighting`
I don’t have this device, but I am familiar with many others and what you describe does not sound correct. With this parameter set to 15, the sensor will not send OFF until 15s after it stops detecting motion. I agree with what @chris4789 is suggesting and this is how all my motion automation works. There is no need for timers or expire, since the sensor takes care of this for you.
Have you tried removing expire and setting parameter 3 to the time you want the light to stay on?
I agree yes I could make it simpler and have the sensor do the expire job but I would have more control my way. For instance what if I want a switch in the OpenHAB UI to turn off motion detection so the manual light switch then acts normally. Doing it in the parameter would essentially hard code the ability so I could not switch it off once set.
I don’t follow you. To disable the automation, just add a proxy Item to the rule that turns the light on and off with motion. If the proxy Item is on, then do nothing, similar to what you have now.
Doh, yep I had a think about my message after I sent it and yes I could do what you suggest. I’ll try thanks. I’ll adjust my rule, will remove the expire and increase parameter the 3 to my prefered expire time.
That’s what you think, but we cannot see it.
With the rules sending commands, your events.log should provide an excellent evidence trail of what is sensed, what your rules are doing and when.
A snippet of a dance session would be good.
I have 2 of the same sensors.
The OFF command is sent 15secs AFTER the movement stopped, not 15 secs after the movement.
That’s why a fixed expire won’t work in this case.
To use a fixed expire the timeout has to set to a very small value (e.g. 1 sec).
rule "Sensor motion changed"
when
Item Swi_MSensor_Motion changed
then
if (Swi_MSensor_Motion_Disable.state == OFF) {
Swi_Light.sendCommand(Swi_MSensor_Motion.state.toString)
}
end
Swi_MSensor_Motion_Disable is the proxy Item for disabling the rule.