I want to know if some one “came in” or “left” the house. To do this I have a motion sensor in the room and a door sensor.
The idea is if the motion sensor was triggered before the door sensor, some one left the room and vice versa.
The problem is my script does not work and I dont know why. Some times its right some time its wrong.
– script
function who_is()
local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1” – Security Sensor Service ID
local DEVICE_NO_SENS_P = 9 – Door sensor
local DEVICE_NO_SENS_E = 31 – Motion sensor
local sensor_door = luup.variable_get (SS_SID, “LastTrip”, DEVICE_NO_SENS_P) or os.time()
local sensor_motion = luup.variable_get (SS_SID, “LastTrip”, DEVICE_NO_SENS_E) or os.time()
sensor_door = tonumber (sensor_door)
sensor_motion = tonumber(sensor_motion)
if (os.difftime (sensor_motion, sensor_door) > 0) then
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Some one left”, Recipients = “Mobil”}, 35)
else
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Some one entered”, Recipients = “Mobil”}, 35)
end
end
luup.call_delay (“who_is”, 60)
return true