I have added my items manually so I don’t have an items file.
When I walk in front of the motion sensor the log shows…
2018-02-14 23:12:26.249 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_ack changed from 88 to 89
2018-02-14 23:12:26.256 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_sof changed from 175 to 176
2018-02-14 23:12:30.527 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_sof changed from 176 to 177
2018-02-14 23:12:30.544 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_ack changed from 89 to 90
2018-02-14 23:12:30.558 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_sof changed from 177 to 178
2018-02-14 23:12:34.613 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_sof changed from 178 to 179
2018-02-14 23:12:34.629 [vent.ItemStateChangedEvent] - zwave_serial_zstick_80b4c831_serial_ack changed from 90 to 91
Here’s the rule…
var Timer myTimer_FR_Motion = null
val int timeoutMinutes = 2
rule "Family Room Motion"
when
// This is the Motion Sensor Item that will trigger to turn on the light. State “ON” means when the sensor detects motion.
Item FR_Motion changed to ON
then
// you will want to create a rule which determines when it is day and when it is night. once you have implemented
// day night states, you can enable the following line. remember to uncomment the last brace at the bottom too.
// if ( nightstate.state==on && lt_fr_table.state==off ) {
// this checks to see if there is currently a timer that exists.
if ( myTimer_FR_Motion===null ) {
logInfo(“FRMotion”, “motion detected in the Family Room, turning on lights for {} minutes.”, timeoutMinutes)
// This instructs the Smart Plug to turn ON.
FR_Plug_1.sendCommand(ON)
// This is where to add an additional Smart Plug to turn ON
// PLUGNAME.sendCommand(ON)
myTimer_FR_Motion = createTimer(now.plusMinutes(timeoutMinutes), [|
logInfo("FRMotion", "Timer expired... turning off lights")
// Change Smart Plug to be a Switch thing.
FR_Plug_1.sendCommand(OFF)
// This is where to turn OFF second Smart Plug
// PLUGNAME.sendCommand(OFF)
myTimer_FR_Motion = null
])
}
else {
logInfo("FRMotion", "Motion detected in Family Room rescheduling timer, adding {} minutes.", timeoutMinutes )
myTimer_FR_Motion.reschedule(now.plusMinutes(timeoutMinutes))
}
// Uncomment the following curly brace if you enable the first IF statement above.
// }
end