I am trying to create a scene that performs an action depending if a sensor is tripped or not.
Basically I wish to turn a light on then off a few seconds later (garage door relay) at 11:00PM but I only wish this scene to run if the garage door is open (Tripped status is 1)
So I have created a scene called “Shut garage door if Open”
The scene turns the garage door light on immediately, and then on a one second delay, it turns the light off. (this simulates a garage door button press)
In the Luup section I have written the following code:
trip_state = luup.variable_get("urn:schemas-micasaverde-com:device:MotionSensor:1","Tripped", 12)
if (trip_state == "0") then
return false
end
I’m new to luup code, but from what I have placed in there, it seems that if the tripped state on my door sensor is 0 indicating that the garage door is shut then it will “return false” which should stop the scene from running at this point.
However, even with this luup code in there, the scene always runs the scene, without regard to if the sensor is tripped or not…
what am I missing here?
Check the serviceId being used. It should have a :serviceId: component in it’s name if it’s correct. It needs to be the exact-match string for what Vera expects or it will also not work.
What you are missing is that the first parameter needs to be a service id and not a service type. The variable you have asked for doesn’t exist and so you are getting nil back and the test always fails.
To learn the right string, go to the door decice’s advanced tab and hover the mouse pointer over the “Tripped” word. The mouseover text is what you want.
Or if you are on UI5 and want to avoid using Luup, see the Combination Switch plugin.
[quote=“futzle, post:3, topic:172166”]What you are missing is that the first parameter needs to be a service id and not a service type. The variable you have asked for doesn’t exist and so you are getting nil back and the test always fails.
To learn the right string, go to the door decice’s advanced tab and hover the mouse pointer over the “Tripped” word. The mouseover text is what you want.
Or if you are on UI5 and want to avoid using Luup, see the Combination Switch plugin.[/quote]
Thanks for the mouseover tip, that was exactly what I needed to make this work. I wasn’t sure how everyone knew so easily where to get those values.
Best Home Automation shopping experience. Shop at Ezlo!