i have moved from Fibaro (lua) to openhab and trying to find a solution for my motion sensors rule as it was on fibaro system.
I want to switch lights as long as there is movement.
On lua it was running with a “for” loop
so i have did it with createTimer, triggering per “received update” from motion sensor.
most motion sensors have just a simple contact “open” as long is motion.
the problem is when the timer has expired the lights will turn off
on lua was realized with for loop with 1s sleep and checking if contact is open then stay in loop, when get closed get out loop and turn lights off.
this scenario seems to not work with createTimer and triggering with received update, couse motion will not update as long is motion.
rule "DoorSensor06 Motion Event"
when
Item DoorSensor06_MotionAlarm changed to ON
then
… turn on the light
end
But keep in mind, the sensor will change to off if no motion is detected within 24sec. This will turn off the light very fast. Try to play with expire binding. This looks like the best way.
Yes. That is very unusual kind of motion sensor, or maybe it is installed in a railway station. Are you using something that already has a timer built-in for directly working lights?
event-driven openHAB does not make it easy to deal with steady states, but it can be done. You’ll probably need to separate functions here ; trigger the light on when motion starts, start the delay timer when motion stops.
its fibaro motion sensor.
ive found a solution, its parameter 6. Motion Alarm Cancellation Delay in seconds. (be also carefull with blind time parameter)
thx @ all
its working.
here is final rule with fibaro motion sensor + rgbw + switch. running on latest snapshot #931
maybe it will help someone
//############################
rule "MoLagerunten"
when
Item zwave_device_06074ec7_node43_alarm_motion changed to ON or
Item zwave_device_06074ec7_node13_alarm_motion changed to ON
then
Motion_05_Timer.sendCommand(ON)
end
/////////////
rule "rMoLagerunten"
when
Item Motion_05_Timer received update
then
if (Motion_05_Timer.state==ON ) {
zwave_device_06074ec7_node46_switch_dimmer2.sendCommand(0)
zwave_device_06074ec7_node46_switch_dimmer3.sendCommand(100)
zwave_device_06074ec7_node46_switch_dimmer4.sendCommand(60)
zwave_device_06074ec7_node41_switch_dimmer2.sendCommand(0)
zwave_device_06074ec7_node41_switch_dimmer3.sendCommand(100)
zwave_device_06074ec7_node41_switch_dimmer4.sendCommand(60)
sendCommand(zwave_device_06074ec7_node40_switch_binary, ON)
sendCommand(zwave_device_06074ec7_node24_switch_binary, ON)
} else {
sendCommand(zwave_device_06074ec7_node46_switch_dimmer, OFF)
sendCommand(zwave_device_06074ec7_node41_switch_dimmer, OFF)
sendCommand(zwave_device_06074ec7_node40_switch_binary, OFF)
sendCommand(zwave_device_06074ec7_node24_switch_binary, OFF)
}
end
For the Aeontec Multisensor 6 I let the device do the timing.
There is a device configuration parameter: 3: Motion sensor reset timeout that sends OFF after the last trig. I have set this to 600 which gives a 10 minute no activity timeout.
This sensor always sends an OFF so it can be trusted doing the timing.
The rule is then very simple, but the device sends multiple OFFs (polling?) so I introduced a bool in my rules so that the OFF actions are only executed once:
var boolean onLR = false
rule "MotionCloset"
when
Item ClosetMovement received update
then
logInfo("Motion", "ClosetMovement.state=" + ClosetMovement.state)
if (ClosetMovement.state==ON) {
onLR = true
MotionTimeOn.postUpdate(LocalTime.now().toString() + " (" + LocalDate.now().toString() + ")")
sendCommand(WallplugClosetLamp, ON)
} else {
if (onLR) {
onLR = false
MotionTimeOff.postUpdate(LocalTime.now().toString() + " (" + LocalDate.now().toString() + ")")
sendCommand(WallplugClosetLamp, OFF)
}
}
end