How to override an action for several hours

I have implemented a securty system that, when any of my Netatmo security cameras detect a person around my house, I get a notification in my mobile and, if this happens after sunset, outside lights are turned on for a few minutes.

Sometimes I plan to be in the garden for some hours and I don’t want notifications to arrive or lights to turn on/off everytime a person (myself or my family) is seen.

Until now, I had a boolean variable called “armed_alarm” and a condition “is_alarm_armed” (if armed_alarm = TRUE). I implemented an Alexa routine which sets “armed_alarm” to TRUE/FALSE when I say “activate / deactivate alarm”. Logicblock which controls notification/lights included that “is_alarm_armed” condition.

Today I have improved that system with the possibility to turn off the alarm for 1, 2, 3, 4 or 6 hours so that I don’t have to reactivate the alarm myself, which is something I tend to forget.

I have replaced “armed_alarm” boolean variable by a numeric variable called “minutes_left_before_alarm_is_back_on”

  • If I say “Snooze alarm for 1 hour” Alexa triggers an IFTTT routine which sets “minutes_left_before_alarm_is_back_on” to 60.
  • If I say “Snooze alarm for 2 hours”, Alexa triggers an IFTTT routine which sets “minutes_left_before_alarm_is_back_on” to 120.
  • If I say “Deactivate alarm”, Alexa triggers an IFTTT routine which sets “minutes_left_before_alarm_is_back_on” to 999999.
  • If I say “Activate alarm”, Alexa triggers an IFTTT routine which sets minutes_left_before_alarm_is_back_on" to 0.

In order for “minutes_left_before_alarm_is_back_on” to diminish as time goes by, I have created a new condition called “every_5_minutes” (cada_5_minutos) with a cron condition “*/5 * * * *” (this means “At every 5th minute”). This condition triggers a logicblock which triggers an IFTTT action which performs a mathematical operation: substract 5 to “minutes_left_before_alarm_is_back_on”.

So, for example, if I set “minutes_left_before_alarm_is_back_on” to 120 (2 hours) at 19:03, then it will be 115 at 19:05, 110 at 19:00, 105 at 18:55, etc. Eventually, it will be 0 and then -5, -10, -15, etc.

Note: OK, you are right, it will reach 0 after 117 minutes, not 120 minutes. I don’t care. More precission could be achieved by creating a cron “at every minute” and substracting 1. Or even working with seconds instead of minutes and creating a cron “at every 10th second”, but I want to be nice with IFTTT and Apilio and avoid flooding with events.

The logicblock which sends the notification and turns on the lights when motion is detected is now controlled by a condition which is “minutes_left_before_alarm_is_back_on < 0”. As long as minutes_left_before_alarm_is_back_on is > 0, no notification is sent (or light is turned on at night), and as soon as it becomes negative and motion is detected, notification is sent and light is turned on.

Although I am using this for an alarm, it could be applied to any other action like lights turning on/off when motion is detected/not detected.

1 Like

Hey awesome solution! @teknofilo :bowing_man: I am looking to do exactly the same but turning my lights-timeout-after-3-mins off for an hour at a time (over dinner for example)! I was actually planning on using a condition with a 1hr timeout or a 60-min delayed action chain but I’m going to wait for some new variable/logicblock actions to be released as my lights automation logic is getting a bit too complicated for my brain :exploding_head:

Until now, I was using a 1 hour snooze with the delayed action option, which can be 60 mins maximum. That’s not enough for me because, if I am out in the garden for a barbecue (like this weekend), I will probably be there for 3-4 hours.

This new method gives me more flexibility so I have implemented 1, 2, 3, 4 and 6 hours snooze periods, as well as ‘forever’, and all of them can be activated via Alexa routines (“Alexa, snooze garden alarms for 2 hours”).

1 Like

Sounds like we also need a longer delay then @pebneter and @Anna ! I really like your use of the Alexa voice commands here Luis; I’ve been getting increasingly fed up with voice commands - the initial enthusiasm has very definitely worn off - but if they provide additiona value, like this, then I’m still happy to use them.

I use lots of voice commands with Alexa. The only issue is that you need to remember the trigger phrase exactly word by word, otherwise it will not work. I wish Alexa would allow severa trigger phrases for the same routine (“snooze garden alarm for 2 hours”, “stop garden alarm for 2 hours”, “snooze alarm for 2 hours”, etc.)

1 Like

Hi @teknofilo,
you should revisit the action configuration today and hopefully be delighted to see that the max is now 10 hours instead of 1! :slight_smile:
We just released that little change last week. Good timing :smile:

1 Like

That’s nice, although I am happy with the system I have implemented in this case because you can easily change your mind and say “snooze garden alarm for 2 hours” and, 30 mins later, say “snooze garden alarm for 4 hours”.

With a delayed execution, the alarm would turn off after the first 2 hours period.

1 Like