Getting a rule to fire on Motion

I am simply trying to have a light come on when a motion sensor is triggered. I’ve seen examples (including the estimable Design Pattern: Motion Sensor Timer by Rich) and tried a number of 'When" conditions to no avail. Not even the logInfo message shows up in the log.

The rule is;

var Timer md1Timer = null
val int timeoutMinutes = 1 // choose an appropriate value

rule “FrontBedroomMotionLight received ON”

when

Item MasterBedroomMotion received command ON or
Item MasterBedroomMotion received command V1 or
Item MasterBedroomMotion changed from 0 to 1 or
Item MasterBedroomMotion changed to 1  or
Item MasterBedroomMotion changed to 255 or
Item MasterBedroomMotion received command V1 or
Item zwave_device_7efa0603_node12_sensor_binary received command ON or 
Item zwave_device_7efa0603_node12_sensor_binary received command OPEN or
Item zwave_device_7efa0603_node12_sensor_binary received command CLOSED or
Item zwave_device_7efa0603_node12_sensor_binary received command OFF or
Item zwave_device_7efa0603_node12_sensor_binary received command 'V1' or
Item zwave_device_7efa0603_node12_sensor_binary received command V1

then
logInfo(“Test Motion Detected”)
if(md1Timer === null) {
logInfo(“Turning Front Bedroom Light On”)
zwave_device_7efa0603_node3_switch_binary.sendCommand(ON)
zwave_device_7efa0603_node3_switch_dimmer.sendCommand(100)
md1Timer = createTimer(now.plusMinutes(timeoutMinutes ), [|
logInfo(“Turning Master Bedroom Light Off”)
zwave_device_7efa0603_node3_switch_binary.sendCommand(OFF)
zwave_device_7efa0603_node3_switch_dimmer.sendCommand(0)
md1Timer = null
])
}

else {
    logInfo("Front Bedroom Motion Detected when Timer not yet completed")
    md1Timer.reschedule(now.plusMinutes(timeoutMinutes ))  
}

end

The event.log shows;

2018-02-01 16:53:29.444 [vent.ItemStateChangedEvent] - MasterBedroomMotion changed from OFF to ON
2018-02-01 16:53:39.310 [vent.ItemStateChangedEvent] - MasterBedroomMotion changed from ON to OFF

And the corresponding openhab.log shows;

2018-02-01 16:53:29.443 [DEBUG] [ssage.ApplicationCommandMessageClass] - NODE 12: Application Command Request (ALIVE:DONE)
2018-02-01 16:53:29.443 [DEBUG] [alization.ZWaveNodeInitStageAdvancer] - NODE 12: Starting initialisation from DONE
2018-02-01 16:53:29.443 [DEBUG] [ve.internal.protocol.ZWaveController] - Event Listener org.openhab.binding.zwave.internal.protocol.initialization.ZWaveNodeInitStageAdvancer@2ddb20ce already registered
2018-02-01 16:53:29.443 [DEBUG] [ssage.ApplicationCommandMessageClass] - NODE 12: Incoming command class SENSOR_BINARY
2018-02-01 16:53:29.443 [DEBUG] [dclass.ZWaveBinarySensorCommandClass] - NODE 12: Received SENSOR_BINARY command V1
2018-02-01 16:53:29.443 [DEBUG] [dclass.ZWaveBinarySensorCommandClass] - NODE 12: Sensor Binary report, type=Unknown, value=255
2018-02-01 16:53:29.443 [DEBUG] [ve.internal.protocol.ZWaveController] - Notifying event listeners: ZWaveBinarySensorValueEvent
2018-02-01 16:53:29.443 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 12: Got an event from Z-Wave network: ZWaveBinarySensorValueEvent
2018-02-01 16:53:29.444 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 12: Got a value event from Z-Wave network, endpoint = 0, command class = SENSOR_BINARY, value = 255
2018-02-01 16:53:29.444 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 12: Updating channel state zwave:device:7efa0603:node12:sensor_binary to ON [OnOffType]
2018-02-01 16:53:29.444 [DEBUG] [.serialmessage.ZWaveCommandProcessor] - Checking transaction complete: Sent Message: class=SendData[0x13], type=Request[0x00], priority=Get, dest=12, callback=91, payload=0C 02 80 02
2018-02-01 16:53:29.444 [DEBUG] [.serialmessage.ZWaveCommandProcessor] - Checking transaction complete: Recv Message: class=ApplicationCommandHandler[0x04], type=Request[0x00], priority=High, dest=255, callback=0, payload=00 0C 03 30 03 FF
2018-02-01 16:53:29.444 [DEBUG] [.serialmessage.ZWaveCommandProcessor] - Checking transaction complete: class=ApplicationCommandHandler, callback id=91, expected=ApplicationCommandHandler, cancelled=false transaction complete!
2018-02-01 16:53:29.444 [DEBUG] [ve.internal.protocol.ZWaveController] - Notifying event listeners: ZWaveTransactionCompletedEvent
2018-02-01 16:53:29.444 [DEBUG] [ding.zwave.handler.ZWaveThingHandler] - NODE 12: Got an event from Z-Wave network: ZWaveTransactionCompletedEvent

Any ideas why is the rule not firing?

It is a sensor so it probably is not receiving a command. It is just changing state. Use

Item MasterBedroomMotion changed from OFF to ON
1 Like

Bingo, that did the trick (especially after I fixed my logInfo statement). Thanks again, Rich, you are an OH sage!