Ok I have finally achieved what i wanted to do with the following
I have a scene which is triggered by the respective countdown timer going “ding” which turns the lights off and my way to essentially stop this happening if I do want to keep the lights on is to cancel the timer, I do this by turning the lights on too 100%l, as long as the motion sensor is triggered after this (which hopefully will be impossible not to do) then the lights will stay on and the motion sensor triggering from then on will not do anything as the lights will be on.
I know there is probably ways to make the code a little more efficient (that was never my strong point) but I’m happy for now!
[code]-- String “0” (not counting down) or “1” (counting down).
isCounting68 = luup.variable_get(“urn:futzle-com:serviceId:CountdownTimer1”, “Counting”, 68)
isCounting69 = luup.variable_get(“urn:futzle-com:serviceId:CountdownTimer1”, “Counting”, 69)
– device 34 is party mode switch
skip = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,34)
light51 = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,51)
light52 = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,52)
light51level = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“LoadLevelStatus”,51)
light52level = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“LoadLevelStatus”,52)
if(skip==“1”)then
return false
else
if (luup.is_night()) then
– 51 Hallway
– 69 -Nightlight Hallway timer
if (light51 ==“0”) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “10”}, 51)
luup.call_action(“urn:futzle-com:serviceId:CountdownTimer1”, “StartTimer”, {}, 69)
else
if (light51 ==“1”) and (isCounting69 ==“1”) and (light51level ~=“100”) then
luup.call_action(“urn:futzle-com:serviceId:CountdownTimer1”, “RestartTimer”, {}, 69)
else
if (light51 ==“1”) and (isCounting69 ==“1”) and (light51level ==“100”) then
luup.call_action(“urn:futzle-com:serviceId:CountdownTimer1”, “CancelTimer”, {}, 69)
end
end
end
-- 52 Landing
-- 68 LandingNighlight Time
if (light52 =="0") then
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "10"}, 52)
luup.call_action("urn:futzle-com:serviceId:CountdownTimer1", "StartTimer", {}, 68)
else
if (light52 =="1") and (isCounting68 =="1") and (light52level ~="100") then
luup.call_action("urn:futzle-com:serviceId:CountdownTimer1", "RestartTimer", {}, 68)
else
if (light52 =="1") and (isCounting68 =="1") and (light52level =="100") then
luup.call_action("urn:futzle-com:serviceId:CountdownTimer1", "CancelTimer", {}, 68)
end
end
end
return true
end
return true
end
– Actions for countdowntimer are: StartTimer, RestartTimer, CancelTimer, ForceComplete
[/code]