Background:
- I have installed Openhab2 on Ubuntu
- I would like to control legacy X10 devices as well as z-wave devices via OH2 and the Smartthings Hub
- I have installed into OH2 the CM11A Binding, and a Smartthings Binding
- I CAN turn on/off X10 lights from Paper UI
- I CAN turn on/off z-wave lights connected to the Smartthings hub via the PaperUI
- I can see motion from a z-wave detector connected to Smarthings (active|inactive) within my OH2 log file
Situation
I have created a rule so that the X10 lights turn off after a period of no activity of the motion detector. I saved the rule in /etc/openhab2/rules as motion.rules and can see in the log file that the script is read.
openhab.log:2017-05-25 08:19:56.516 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'motion.rules'
###--------Items----------###
Contact BasementSensor “Basement Motion Detector [MAP(contact.map):%s]” { channel=“smartthings:motionSensor:Home:BasementSensor:motion” }
Switch SwitchC1 “Basement Stairs” (someGroup) { channel=“cm11a:switch:MyCm11a:SwitchC1:switchstatus” }
###-----motion.rules----####
var Timer timer
rule "motion for 30 seconds"
when
Item BasementSensor changed
then
logInfo(“basement_motion”, “motion was triggered”)
if(BasementSensor.state == CLOSED)
{
timer = createTimer(now.plusSeconds(30)) [|
sendCommand(SwitchC1, OFF)
]
}
else
{
if(timer!=null)
{
timer.cancel
timer = null
}
}
end
Result
I CAN see the motion detector firing in the log file:
2017-05-25 15:42:05.226 [INFO ] [ngs.handler.SmartthingsBridgeHandler] - Smartthings updated State for device: Basement Motion Detector - motion to inactive
But the rule is NOT triggered. I’m pretty sure I’ve screwed up the install or am missing something pretty basic. Any thoughts?
Furthermore
Just for the fun of it I created a very simple rule (write to the log when a switch is active) and cannot get it to fire either when I turn on the switch.
###-----switchtest.rules—###
rule "switch test"
when
Item SwitchC1 received update
then
logInfo(“test”,“it worked!”)
end