Hi All,
I know this is a frequently covered topic but after months of testing and tweaking I am giving in and asking for help.
I have a scene that is triggered by motion in that area or the door being opened.
I then have it check if it is daytime and if not, turn the light on and set a timer for 6 mins with in the function. The idea being that if the scene is triggered again, the timer will be reset to 6 mins again and count down (to the Off function).
What is happing though is unpredictable. It most of the time comes on, but too often it will come on the turn strait back off. Or now that i added to check the status of the light, it may never turn on. The last part probably due to the dimmers being LightwaveRF dimmers which do not seem to transmit their status only receive a command so Vera can get out of sync when someone manually hits the switch.
Can someone cast an eye over this script and tell me where I am being an idiot and if they can think of a way to compensate for the lack of transmit from the switch (some kind of normalisation using LastTrip time maybe of the PIR in that area?)
I did originally use the call_delay function but i found that to just flash the lights also, i am guessing it was queuing up delays and sending off commands, hence trying to create a resettable timer for OFF.
local HallwayLight = 85
local day = luup.variable_get(“urn:rts-services-com:serviceId:DayTime”, “Status”, 105)
local SES_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”
local Dimmer_SID = “urn:upnp-org:serviceId:Dimming1”
local LightStatus = luup.variable_get( Dimmer_SID, “LoadLevelStatus”, HallwayLight)
function HallwayLightsON ()
if (day == “0”) and (LightStatus == “0”) then
luup.call_action( Dimmer_SID, “SetLoadLevelTarget”, { newLoadlevelTarget = “100”}, HallwayLight)
luup.call_timer(“HallwayLightsOFF”, 1, “6m”, “”, “”)
elseif (day == “1”) and (LightStatus >= “1”) then
HallwayLightsOFF()
end
end
function HallwayLightsOFF ()
if (LightStatus >= “1”) then
luup.call_action( Dimmer_SID, “SetLoadLevelTarget”, { newLoadlevelTarget = “0”}, HallwayLight)
end
end
HallwayLightsON ()