It does exactly what it should!
First of all: understand, what your sensor does - and this is behaviour #1 in my previous post:
- it sends ON if it detects movement
- it does nothing for a configurable time (in that case 5sec)
- it sends OFF (regardless of motion in between first movement detection)
- it sends ON again, if there’s (still? you won’t know) movement
so, keep this always in mind - That logic is as it is and you can only change the interval from 5secs to 5mins or whatever).
so, what you have to do is to take those two events (ON and OFF) - and bring it in correlation. Your goal is obviously to turn the light on (and let it burn) while there’s movement. and turn it off, if there’s no more movement, isn’t it?
so, you have to have an expire-intervall, which is longer than the sensor-intervall in your zwave. How much longer depends on the use of the room and the position, the sensor is placed. you can have short intervalls in your zwave sensor and a long one in expire, so the light will not turn off eventually, if someone is still in the room but either in a dead angle or just not moving (like - watching TV, staring in the computer screen or whatever).
For a better understanding, use two rules then:
Item Sensor_Office_Motion changed to ON
// do something: I guess, turning on your dimmer_office and logInfo it (as you already did)
(remember, if you just restarted OH2 for some reason, the Change will be from UNDEF to ON! that’s why I left out the from part.)
theres a difference between
changed to and
received command - even if your item received the command ON from the sensor if it still had the state ON, it didn’t change - see?
Item Sensor_Office_Motion changed to OFF
// do something: If you expired the Dimmer_office you won't turn it off, but at least logInfo the event to understand your sensor's behaviour (at least until everything works, then you can turn logging it to OFF #SPAM
so, and now to the first part of your question:
if you have a
String item, you want to have
If Item == '<STRINGVALUE>' (with quotes) in your rule. if you have
If Item == <Number> (without quotes). And if it’s
Switch in your case, you want it
If Item == <ON/OFF>.
So, now to your problem: If your sensor sends
OFF from itself, you won’t need the expire-part on openHAB side with
Sensor_Office_Motion, do you? so, put the expire-part on your
Dimmer_Office item and play around as I said with both intervals until it fits your needs.