I’m relatively new to this and am not a programmer by any means.
I have a landing light set to turn on and off based on motion and lux sensor (Fibaro Multisensor).
This works fine, however I would like to improve it a little as the light is currently set to come on if the lux sensor is <70, which is a little too light for my liking!
I did lower the lux sensor condition to be <60 after checking the logs to see at which point the light should be triggered.
However, this caused an interesting problem. Once the light had been triggered on, then turned itself off again due to no motion the lux sensor had logged the new value of 65 (while the light was on) then does not update quick enough after the light has been switched off to allow the light to turn back on if motion is detected in a short time frame.
It’s main use is for if anyone goes to the bathroom in the night, so the light turns on fine when going to the bathroom, turns off while in the bathroom then does not always turn on again when leaving the bathroom due to the lux sensor being above 60 while the light was turned on.
Is there a way to force the lux sensor to update after the light has turned off?
Switch LandLight “Landing Light” {channel="zwave:device:***, expire="20s,command=OFF"} // turn off the light after 20 seconds
You need to set up persistence on LandLight. If you are not already using persistence, use MapDB.
rule "Landing Motion"
when
Item land_motion changed to ON
then
// If the light is already on, keep it on for another 20 seconds
if(LandLight.state == ON) {
logInfo(loglight, "Landing Light switch kept ON")
LandLight.sendCommand(ON) // keep the light ON and reset the timer
}
// if the light is OFF, turn it on if it is dark OR the light turned OFF less than 5 seconds ago
else if(land_lum.state < 70 || LandLight.lasUpdate("mapdb").isAfter(now.minusSeconds(5)) {
logInfo(loglight, "Landing Light switch ON")
LandLight.sendCommand(ON)
}
end
Thank you @rlkoshak, I don’t have persistence set up so will look into that first. I have added the expire binding to my setup so will be using that quite a bit I think.
I’m assuming I would need to make an individual expire switch Item for each instance within my rules for instance a LandTimer, DoorTimer etc.
While you cannot query the current lux value, Fibaro FGMS have a parameter (#40) to report illumination whenever it changes by a defineable amount. That should apply when you turn off the light.
Because of the device you’re using, I think there is a much simpler way to achieve this. Your device has a LOT of configuration parameters for tuning it, so you shouldn’t need to use a timer, the Expire binding, or persistence. If you are using the default settings, it looks like you would want to set parameter 6 to 50 (default 30s + 20s). Also, setting parameter 8 to 2 will allow the motion sensor to only trigger during the night, and setting parameter 9 to 60 should set the lux level for the day/night transition. You’ll probably also want to take Markus’ advice and adjust parameter 40 for the lux reports too. Your rule would then collapse to a simple:
rule “Landing Motion”
when
Item land_motion changed
then
LandLight.sendCommand(land_motion.state)
logInfo(loglight, “Landing Light switch {}”,land_motion.state.toString)
end
But there’s actually no reason to use a rule at all, because the information used is already in the device! Just add the node ID of the light switch to Association Group 2 or 4 (in the motion sensor), depending on it’s capabilities, and the motion sensor will send the ON/OFF directly to the light. Once setup, you wouldn’t even need OH running or your ZWave controller plugged in for the light to turn on with motion. The time between motion detection and the light turning on will also be quicker than going through a controller.
I like your device… but that eye ball creeps me out!
Actually, if you send the command RefreshType.REFRESH to an item, the ZWave binding will request the current value from the device.