I would like to put LUUP code into a scheduled loop that would run every 15 minutes for example, and that would check if the door lock is unlocked since that last 15 minutes, if so then write something in the log for example.
I got this part I think that will give me if the door is locked or not…
…
local LOCKDEVICE= 12 – The Door Lock device number
local LOCKSTATE = luup.variable_get (“urn:micasaverde-com:serviceId:DoorLock1”, “Status”, LOCKDEVICE)
…
…but I?m not sure which variable will tell me WHEN it was locked or unlocked? Normally for my sensors, I use something like this;
local LASTTRIP = luup.variable_get(“urn:micasaverde-com:serviceId:DoorLock1”, “LastTrip”, LOCKDEVICE) or os.time()
if (LOCKSTATE == “0” and (os.time() - LASTTRIP >= DELAY)) then
luup.log(?xxxxx?)
end
…
But obviously this is not the variable I need for my door lock
Can anyone help me finalizing this code please
Thank you
Claude
Further more (assuming I’m still in the right forum)
I also have a DSC alarm that I would like to query the status of the “ArmMode” (Armed or Disarmed) and also WHEN that Arming (or Disarming) was done… but once again, I can’t seem to find which variables to query for this.
Anybody can help with the LUUP syntax I would need for that???
Thanks
You could try set up a variable_watch for “Status” in startup lua script (Apps/Developer apps/ Edit Startup Lua). In variable_watch function set a “LastLock” variable and use this in your actual script.
Ok thanks for the info, but unfortunately I don’t understand… Can you elaborate exactly what is the “variable_watch function”? what does it do? what is it used for? it seems like just an input-box to enter some LUUP code in there… (and When is this code triggered/executed? startup of what?
Why didn’t I need to use this “variable_watch function” for checking When my sensor was last tripped?
Thanks for your help
If I got this , you want to see if in the last “X” minutes your door lock was unlocked, right? But you don’t have a variable like “LastTrip” for this. OK then, let’s make one. To do so, go to “Apps/Developer apps/ Edit Startup Lua”. If you enter some Lua code here, it will be executed at every LuaUPnP startup. Now set here a “variable_watch” for “Status” variable from your door lock. Try this link to see how you can do this : http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_variable_watch. The first parameter is a function that is called whenever the UPnP variable is changed for the specified device. In this function you can set a variable, lets say “LastUnlock”. After doing this, use it in your scene like you use “LastTrip” variable.
But you don't have a variable like "LastTrip" for this
Well my initial question or rather My initial hope was that for the DoorLock, there WAS a variable like "LastTrip" that I didn't know about, and so my question was How to know what is that variable called.
Now if there isn't one then Thank you, yes, I can try to figure out what you suggest... and so my new question is What does this mean:
it will be executed at every LuaUPnP startup
What is a "LuaUPnP startup", is it triggered every time my veralite is rebooted?
DoorLock doesn’t have a variable like “LastTrip”, but as i was saying you can make one.
The code inserted in “Edit Startup Lua” will be executed every time when your Vera is starting up. If you set up a “variable_watch” here for “Status” variable on DoorLock, every change on its value will be spotted by variable_watch, no matter when this will happen. To be more specific, from the point when you set up the variable_watch for a variable, its value will be monitored as long as your Vera is still running. So every time your door is locked/unlocked will trigger a call for the function given as parameter in variable_watch.
function Lock12TimeStamp()
Last12Status = os.time()
end
luup.variable_watch("Lock12TimeStamp", "urn:micasaverde-com:serviceId:DoorLock1", "Status", 12)
I expected to struggle a little, but No.
(powerful stuff)
Thanks for the good info
[quote=“fouclo62, post:8, topic:177665”]Wow, that worked on my first attempt…
function Lock12TimeStamp()
Last12Status = os.time()
end
luup.variable_watch("Lock12TimeStamp", "urn:micasaverde-com:serviceId:DoorLock1", "Status", 12)
I expected to struggle a little, but No.
(powerful stuff)
Thanks for the good info[/quote]
So man this is all greek to me but I have to tart somewhere
I want to lock a door every 15min. Couldnt I just set up a schedule in a scene to do this?
Yes you’re right, all you need to do is schedule a scene every 15 minutes to lock your door. What I was trying to achieve here was send me an [alert] if my door had been unlocked for more than 15 minutes. (and I ended up using the variable-container plugin to do this… works like a charm)
Best Home Automation shopping experience. Shop at Ezlo!