How to cancel delayed event

Hello,

How can I cancel a delayed event. For example when a sensor is triggered and after a certain time a sirene should be switched on except when de-armed within this time period.

Thanks in advance

If you’re talking about delayed actions in a triggered scene then, AFAIK, you can’t.

You would need separate scenes and some Lua code. Others might suggest looking at the PLEG plugin.

Hi,

You have several choices. Write some LUA code your self that checks if the sensor is disarmed.

You can also give the Rules Engine plugin a try [url=http://forum.micasaverde.com/index.php/topic,34489.0.html]http://forum.micasaverde.com/index.php/topic,34489.0.html[/url]. That cancels any delayed action if you include the sensor armed/disarmed status in the condition.

You can also look at the PLEG plugin. I’m pretty sure that can deal with this situation too.

Cheers Rene

the way i achieve this which I’m sure is not the most efficient is that in scene 1 it uses a delayed action to run scene 2 (using pleg to run said scene), that scene then uses lua code to do a check and return either false, on this basis the scene will either run your actions or not.

during that time I can change the status of that virtual switch and it wont run

Holiday = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",93) if(Holiday=="1") then return false end

If you are into LUA coding, you could modify the following code to suit your needs.

I have a scene switch that turns on the garage light, and automatically turns off the light in 5 minutes. If I press the light twice in sucession, the time is extended to 10 minutes (a third press makes it 30 minutes). Pressing that scene switch at any time while the light is on will restart the time counter.

function GarageTimer(stuff)
  gGarageTimer = gGarageTimer - 1
  if (gGarageTimer > 0) then
    luup.call_timer("GarageTimer", 1, "15", "", "")
  elseif (gGarageTimer == 0) then
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },37)
  end
end
if (gGarageTimer == nil) then
  gGarageTimer = 0
end
if (gGarageTimer <= 0) then
  luup.call_timer("GarageTimer", 1, "15", "", "")
end
if (gGarageTimer < 20) then
  gGarageTimer = 20
elseif (gGarageTimer < 40) then
  gGarageTimer = 40
elseif (gGarageTimer < 120) then
  gGarageTimer = 120
else
  gGarageTimer = 0
end

The above code checks the countdown timer every 15 seconds, so the gGarageTimer is set to the number of minutes * 4.

if I want to “cancel” the timer, I can just set the global variable “gGarageTimer” to -1. If I want to cancel the timer and turn off the light, I set gGarageTimer to 1.

Hope this gives you an idea on how to proceed. However, as stated earlier, PLEG might be a simpler solution.