I have openHab 2.5.12 running on Raspberry Pi 3+. I know this is not a supported version and I shall switch to the OH3 system and I do really consider that.
Before doing that I wish to understand and improve quite a basic topic which is a delay in communication.
Configuration
In one of my rooms I have FIBARO Motion Sensor which switches two independent and grouped lights controlled by FIBARO Double Switch 2. Control is defined in the rule below. If it is quite dark and motion in the room is being recognised, lights are switched on. If no movement is recognised within 7 min lights will switch off. If the movement will be recognised before time elapses, the timer will be restarted.
This functionality works and this is the rule:
Group:Switch:OR(ON, OFF) gLightMainOffice "Light" <light> (Home) ["Lighting"]
Switch BS_Office_Main_Light_1_Switch "Light Gosia [%s]" <light> (BS_Office, gLight, gLightOffice, gLightMainOffice) ["Lighting"] {channel="zwave:device:8985008e:node39:switch_binary1"}
Switch BS_Office_Main_Light_2_Switch "Light Jacek [%s]" <light> (BS_Office, gLight, gLightOffice, gLightMainOffice) ["Lighting"] {channel="zwave:device:8985008e:node39:switch_binary2"}
var Timer timerFlur = null
val int timeoutMinutes = 7
rule "Office Motion Sensor ON"
when
Item BS_Office_Motion changed from OFF to ON
then
logInfo("Motion Office", "Luminance in Office: "+ BS_Office_Luminance.state.toString)
(timerFlur === null || timerFlur.hasTerminated) {
timerFlur = null
gLightMainOffice.sendCommand(ON)
logInfo("Motion Office", "Movement recognised -> Light ON")
}
else {
timerFlur.cancel
timerFlur = null
logInfo("Motion Office", "Movement recognised -> Timer restart.")
}
end
rule "Office Motion Sensor OFF"
when
Item BS_Office_Motion changed from ON to OFF
then
logInfo("Motion Office", "No more movement -> Timer start.")
timerFlur = createTimer(now.plusMinutes(timeoutMinutes), [ |
timerFlur.cancel
timerFlur = null
gLightMainOffice.sendCommand(OFF)
logInfo("Motion Office", "Timer elapsed -> Light OFF")
])
end
The Problem
Sometimes (usually after a longer period of no interaction between sensors) lights are switched on within a few (10-12) sec. delay. I measure it from the time I observe the PIR sensor to flash the light when movement has been recognised.
Target: to eliminate the delay or make ist very very short.
I know there is a possibility to associate the sensor and lights switches so the light is toggled without questioning the controller. Would it improve the situation?
How shall the rule be changed to keep the 7 min wait state and analyze the motion in the room if association will be made? Should it at all or is the rule independent from the communication way?