Need help installing Aeotech Z-Stick Gen 5 on RPi

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.

Copied and same result after changing colons to underscores.

tplinksmarthome:hs105:4411DE:switch

Another Case problem in sendCommand on Line 18.

I had already fixed that one. Must be another somewhere… Checking.

The error says Line 18. Sometimes it can be right before or after if quotes are involved, but I would stick to that line number. Go ahead and paste the current version of the code.

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

Send a screen shot of the Tplink light Item. You may of unintentionally unlinked it. In the blue circle is the center solid white? If you go to the Control page of PaperUI do you see the Light with a switch control that works to toggle the light?

Click on the outside blue area of the circle. That will show you what it is Linked to (Linked Item). You want that item in Grey like my examples above.

FRPlug_1

Change both the ON and the OFF lines.

1 Like

:grinning::+1:

Wow, what a journey! So if I want to use this rule for another sensor and light, do I add it to the same file?

I’ll take that as it works!

I would say you learned a lot in this exercise. Good for you.

No, but you can copy it and change just a few items AND the names of the Timers (don’t think they are local to the Rule itself, so each rule would need it’s own unique Timer name. The core of the Rule can remain the same.

I think the next place that you will take this motion sensor is to learn about only turning on lights when it’s night or dark. There are examples of how to do that in the forum. I and many others can help with that. I hope you see that OH2 is very powerful, and I welcome you to the Smarthome!

Do you have any other questions?

Tony

Thanks again Tony!

So I understand, I probably should name rules files more specifically. For example, instead of motion.rules I should name it FRmotion.rules for Family Room, BRmotion.rules for Bedroom etc? I agree, I need to get the day/night check included.

I need to read the Rules docs and try something else. One question, do OpenHAB users typically find one brand of smart plug, switches and sensors and stick with it throughout the house? I suppose it would make sense but just curious. Where do most people buy their plugs, switches, sensors etc?

Yes, you can create a rule for each, but rules can be placed into the same file. So for related rules you might combine them into one file, but you could definitely use separate files for sure. To combine, you simply repeat the whole rule a few lines after the first.

I think that you should find Examples in the Forum, or in the docs that you would like to try. I often refer back to a rule that I may of worked on before to borrow sections or calls. Often for the Logging syntax or the sendCommand, or the trigger example. Some real easy ones are simply turning on or off a light based on time. Here’s a teaser for you! See if you can use the info you just learned to get these two working for your lights. Those cron lines are in Quarts Cron format.
https://docs.openhab.org/configuration/rules-dsl.html#time-based-triggers

rule "Early Lights On"

when
    Time cron "0 20 6 ? * MON-FRI"
then

    logInfo("logInfoMorning", "Waking up. Turning on early morning lights")

    sendCommand(Lt_Dining_Room, ON)
    sendCommand(Lt_FR_Table, ON)
    sendCommand(Lt_Kitchen, ON)
    sendCommand(Lt_Kitchen_Sink_Color, "0,0,100")
end
rule "Turn some more lights off"
when
        Time cron "0 0 22 ? * *"
then
        logInfo("RULE", "Lights Out: Turning off the Dining Room Lights")
        sendCommand(Lt_Dining_Room, OFF)
        sendCommand(Lt_Office, OFF)
end

As for devices, I have shopped around and looked for quality items. I don’t like to pay much more than about $40 for a plug, switch, or device. Some I buy off of Amazon, some I buy from other online vendors. I almost always search these forums for review or issues that others are having. The OH2 Z-Wave Binding is really good, so with a good Controller like you have things should go mostly smoothly. I think one thing you should think about is what is the right device to buy. The Bulb, a Plug, or a wall Socket all do the same thing. They control a light. But they all have their Pro/Cons. I think I like the Plugs the best for their portability. I can test certain locations and change my mind. I do have several physical wall switches and those are good too. Think before you buy and you will be happy in the end.

I’m happy to have worked through this with you.

Good Luck in your Journey! It’s a marathon, not a sprint.

Cheers!

1 Like

And I appreciate your patience with me! I’m glad I can put multiple rules in one motion.rules file. That’s what I was asking earlier but may not have been very clear. I’ll keep reaching out in the Beginners section when I come across something I need help with. Hopefully sometime in the future I’ll be able to help someone too!

1 Like

@Toneus… FYI. I’ve noticed something. I’ve been using Simple Mode for Item linking when I add new Things. The problem is, I have to turn that off in order to be able to click the outside part of the blue circle to see what that Thing is linked to. With Simple Mode enable, I can’t a “Could not find item” error.

Interesting. I did not know that was a restriction. Personally, I define all of my Items in a file format. That keeps everything in one place and allows me to connect to a known Item name. You experienced this in the coding fun we had together.

For me, it simplifies my rule writing. I know what the name will be. AND, if I have to rebuild my environment, I don’t have to edit all of my rules. I simply re Link my Things to the correct Item.

You can go through the Items listing, doesn’t that display all of the Items available?

I prefer the Items file approach.