Need help installing Aeotech Z-Stick Gen 5 on RPi

Yep, rule won’t load. Something is amiss.

2018-02-08 19:29:23.479 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘motion.rules’ has errors, therefore ignoring it: [7,6]: no viable alternative at input ‘(’

Did you copy the string from the Item, and it is really named burglar? You can see in my screen shots above that the name of my Item in light grey is Kitchen_Motion. It is the linked Item.

And then also on the Light, the name is??? Again, mine in light grey is Lt_Kitchen. Just verify those. If you think it’s right, then save the file in the rules folder. Then take a look at the log (/var/log/openhab/openhab.log), it will tell you if it finds error on save.

Ok, that says line 7, position 6. I think it’s complaining about burglar not being correct.

Yes… here’s a screenshot.

The light is named is Switch. That’s how the TP Link plug thing is named. Can I change it to be more descriptive?

Nope, it is zwave_device_80b4c831_node2_alarm_burglar.

Use the two square boxes to copy it to your clipboard.

Ah… okay! Let me try that.

How about this? I fixed the light too.

var Timer myTimer_KT_Motion = null
val int timeoutMinutes = 3

rule "Kitchen Motion Detection"
when
// The following Item Alarm (burglar) should be the Thing that the Channel is Linked to in Paper UI.
Item Alarm (burglar) 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_kt_motion===null ) {
loginfo(“ktmotion”, “motion detected in the Family Room turning on lights for {} minutes.”, timeoutminutes)

// change Switch to be a switch thing.
Switch.sendcommand(on)

// I have two lights that I turn on for motion
// Lt_FR_Table.sendCommand(ON)

     myTimer_KT_Motion = createTimer(now.plusMinutes(timeoutMinutes), [|
     logInfo("KTMotion", "Timer expired turning off lights")

// Change Switch to be a Switch thing.
Switch.sendCommand(OFF)

// Turning off my second light
// Lt_FR_Table.sendCommand(OFF)

     myTimer_KT_Motion = null
     ])
  }
  else {
     logInfo("KTMotion", "Motion detected in Kitchen rescheduling timer, adding {} minutes.", timeoutMinutes )
     myTimer_KT_Motion.reschedule(now.plusMinutes(timeoutMinutes))
  }

// Uncomment the following curly brace if you enable the first IF statement above.
// }

end
[19:27:06] openhabian@openHABianPi:/etc/openhab2/rules$ vi motion.rules
[19:29:23] openhabian@openHABianPi:/etc/openhab2/rules$ vi motion.rules
[19:50:35] openhabian@openHABianPi:/etc/openhab2/rules$ !!
vi motion.rules
[19:51:24] openhabian@openHABianPi:/etc/openhab2/rules$ vi motion.rules
[19:52:22] openhabian@openHABianPi:/etc/openhab2/rules$ more motion.rules
var Timer myTimer_KT_Motion = null
val int timeoutMinutes = 3

rule "Family Room Motion"
when
// The following Item zwave:device:80b4c831:node2:alarm_burglar should be the Thing that the Channel is Linked to in Paper UI.
Item Alarm zwave:device:80b4c831:node2:alarm_burglar 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_kt_motion===null ) {
loginfo(“ktmotion”, “motion detected in the Family Room turning on lights for {} minutes.”, timeoutminutes)

// change tplinksmarthome:hs105:4411DE:switch to be a switch thing.
tplinksmarthome:hs105:4411DE:switch.sendcommand(on)

// I have two lights that I turn on for motion
// Lt_FR_Table.sendCommand(ON)

     myTimer_KT_Motion = createTimer(now.plusMinutes(timeoutMinutes), [|
     logInfo("KTMotion", "Timer expired turning off lights")

// Change tplinksmarthome:hs105:4411DE:switch to be a Switch thing.
tplinksmarthome:hs105:4411DE:switch.sendCommand(OFF)

// Turning off my second light
// Lt_FR_Table.sendCommand(OFF)

     myTimer_KT_Motion = null
     ])
  }
  else {
     logInfo("KTMotion", "Motion detected in Kitchen rescheduling timer, adding {} minutes.", timeoutMinutes )
     myTimer_KT_Motion.reschedule(now.plusMinutes(timeoutMinutes))
  }

// Uncomment the following curly brace if you enable the first IF statement above.
// }

end

Another error in the log…

2018-02-08 19:51:24.554 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘motion.rules’ has errors, therefore ignoring it: [7,6]: no viable alternative at input ‘zwave’

Sorry, change all of the colons to underscores.

Still getting an error…

2018-02-08 20:00:33.572 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘motion.rules’ has errors, therefore ignoring it: [7,6]: no viable alternative at input ‘zwave_device_80b4c831_node2_alarm_burglar’

Yours

Mine

Get rid of Alarm, and correct on to be ON upper case.

Okay, getting closer. The rule didn’t give an error in the log when I saved it. However, it did give an error when I triggered it.

2018-02-08 20:08:19.315 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Family Room Motion’: The name ‘mytimer_kt_motion’ cannot be resolved to an item or type; line 14, column 12, length 17

Do you still have these lines at the top of your file?

The var Time myTimer_KT_Motion is where the timer is being declared.

Here’s the entire rule…

var Timer myTimer_KT_Motion = null
val int timeoutMinutes = 3

rule "Family Room Motion"
when
// The following Item zwave:device:80b4c831:node2:alarm_burglar should be the Thing that the Channel is Linked to in Paper UI.
_ Item zwave_device_80b4c831_node2_alarm_burglar 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_kt_motion===null ) {_
_ loginfo(“ktmotion”, “motion detected in the Family Room turning on lights for {} minutes.”, timeoutminutes)_

// change tplinksmarthome:hs105:4411DE:switch to be a switch thing.
_ tplinksmarthome_hs105_4411DE_switch.sendcommand(ON)_

// I have two lights that I turn on for motion
// Lt_FR_Table.sendCommand(ON)

_ myTimer_KT_Motion = createTimer(now.plusMinutes(timeoutMinutes), [|_
_ logInfo(“KTMotion”, “Timer expired turning off lights”)_

// Change tplinksmarthome:hs105:4411DE:switch to be a Switch thing.
_ tplinksmarthome_hs105_4411DE_switch.sendCommand(OFF)_

// Turning off my second light
// Lt_FR_Table.sendCommand(OFF)

_ myTimer_KT_Motion = null_
_ ])_
_ }_
_ else {_
_ logInfo(“KTMotion”, “Motion detected in Kitchen rescheduling timer, adding {} minutes.”, timeoutMinutes )_
_ myTimer_KT_Motion.reschedule(now.plusMinutes(timeoutMinutes))_
_ }_

// Uncomment the following curly brace if you enable the first IF statement above.
// }

end

Yours

Mine

Case matters sometimes. Change yours to myTimer_KT_Motion.

It appears that you typed this in. You probably should have Copy Pasted and then edited the Pasted copy.

That’s really weird, I did copy/paste from your post above to my vi editor with the file open. Let me try that and report back.

New error when triggered…

2018-02-08 20:26:46.176 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Family Room Motion’: The name ‘loginfo’ cannot be resolved to an item or type; line 15, column 10, length 107

You should check each error for a Case difference between yours and mine. It should be logInfo with a Capital ‘I’.

There are a couple of those in the Rule. Check them all.

Getting closer…

2018-02-08 20:46:07.939 [INFO ] [ipse.smarthome.model.script.ktmotion] - motion detected in the Family Room turning on lights for 3 minutes.

2018-02-08 20:46:07.944 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Family Room Motion’: The name ‘tplinksmarthome_hs105_4411DE_switch’ cannot be resolved to an item or type; line 18, column 10, length 35

Yes you are. Ok, so the motion is detected and Timer is probably being activated. I would double check the long name of the light switch. Use the same Copy function (two squares icon) and then take the colons out. I’m guessing that there should be an underscore between tplink_smarthome.