luup.variable_get() returns 2 things, the value of the variable requested and the time it was last modified. The wiki suggests doing something like to make sure you are using value and not the time:
if( tonumber(lul_temp)<26.6 ) then
The thing is I need the time, not the value.
Im working with a z-wave motion sensor and I need the time that the device “tripped” variable was last changed( it actually changes twice when tripped, first to tripped=1 then back to tripped=0 a few minutes later, but thats fine).
try it first, and make sure your experience matches. I wouldn’t be discouraged on this stuff, as what can “fail” in early releases, can often work later on when it’s fixed (or it’s functionality is better understood)
Is there an easy way to pull the current time in unix format?
can anyone tell me why this does not work on vera2 with the latest beta, this is my first attempt. the device that I am using is the hsm100. The device works just fine I am just trying to add a condition. e3 is the device id for the temp. if i use the the device master id #5 it tells me “Bad Device”
if( tonumber(lul_temp)>10 ) then
Goal: Every day at 11:00 send me an email if motion senson 1 hasn’t tripped in the last 4 hours. ( I want to make sure my dad is up and moving around.)
Plan: I am planning to use the timespamp on the Motion sensor’s “Tripped” variable to calulate how long since the last time it was tripped. If at 11:00am it hasnt been tripped in 4 hours send an email.
Monkey wrenches: From what I’ve seen, I have to set up a scheduled scene to send the email, then if the sensor has tripped, prevent the sending. which makes the code “feel backwords”. Email alerts are seamingly tied to the motion sensors tripped state which I can’t rely on.
Scene setup: I have scene named “Dad not up”. In it is a timer, set for 11:00 AM daily. There is an event I’ve lovingly named “stupid settings” with the selected device being Device “#47 Motion Sensor” Event type “An armed sensor is tripped”, and Tripped? “No”. All this seems very awkward and kludgy but was nessicary to expose the notify checkbox. which I have of course clicked.
Code: In the luup scene code box I have the following(Im using 1200 seconds as a test for now):
local ght_tripped, ght_tripped_time=luup.variable_get(“urn:schemas-micasaverde.com:serviceId:MotionSensor”,“Tripped”,47)
if( tonumber(ght_tripped_time)>(ght_current_time-1200)) then
Result: nothing. Even with the code removed I get no emails, which is confusing since Iwith no code to stop them I should be getting the emails automaticly when the timer goes off. I assume that the event code is some how screwing this up, but Im not sure how to get that configured the correct way.
i am trying to use the tab "Test Luua code (Lua) under “MIOS Developers” section of the UI4 to test the code, not sure if this is the correct thing to do. if i use anything else for device other than e3 it gives me Bad Device.