# Gate open timer - incrementing logic variables

**URL:** https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821
**Category:** Questions & Help
**Tags:** app, flow
**Created:** [August 21, 2020, 4:02am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821 "2020-08-21T04:02:17Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [August 21, 2020, 4:02am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/1 "2020-08-21T04:02:17Z")

</div>

I am trying to create a flow which gives an alert if I have left my gates open after a period of time. I created a variable “Gatetimer” and set it to zero. when the gates open I set it to 1, and then “try” and increment the variable by 1 every minute they are still open. My problem is that my Logic arithmetic doesn’t work. After it triggers I gat back a value of “NaN”.  
I have attached the picture of the flows below.  
Can anyone tell me what I have done wrong? And if there is a simpler way of doing this please tell me.

 ![Screen Shot 2020-08-21 at 1.54.05 pm](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/a/1aebfd00123e78243c3eb6b81633d94e2dd55bdc.png) ![Screen Shot 2020-08-21 at 1.54.22 pm](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/2/620d342fc634a493fe68a709df5327e7abb7cb5e.png)

---

<div class="post-metadata">

### Author: ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)
#### Post date: [August 21, 2020, 4:56am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/2 "2020-08-21T04:56:09Z")

</div>

When you calculate you have to use double curly brace {{. You have used a single curly brace {, which gives an error. NAN= Not A Number

---

<div class="post-metadata">

### Author: ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)
#### Post date: [August 21, 2020, 6:17am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/3 "2020-08-21T06:17:27Z")

</div>

If you want to receive only one message after 1 minute (variable “Gate Timer” = 2), you can leave the flows as they are (don’t forget to correct the calculation).  
Because with these flows the variable will not be counted higher than 2. By opening the gate you trigger the flow only 1 time. If the gate remains open, no more triggering will occur.  
If you want to get a message e.g. every 10 minutes if the gate is still open, you could do this with a timer/countdown.

Edit: You can also use „Zones“ if there are no more sensors in this zone.

---

<div class="post-metadata">

### Author: ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)
#### Post date: [August 21, 2020, 10:44am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/4 "2020-08-21T10:44:04Z")

</div>

This is a really simple sample with “Zone” cards.  
You can choose between 1, 5, 10, 15, 30, 45, and 60 minutes.  
No other flows are needed.

---

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [August 22, 2020, 8:49pm UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/5 "2020-08-22T20:49:43Z")

</div>

Thanks for the advice re the need to double brackets, and on the tip for using zones, I have used zones at all so far.  
The timer does increment however as each time it is incremented the value has changed so it increments it again after the 60 secs delay. It seems to be working well except for some fine tuning and getting it to stop and setting the timer back to zero. So a little bit more think8ng required when I get some more time.

---

<div class="post-metadata">

### Author: ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)
#### Post date: [August 23, 2020, 11:03am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/6 "2020-08-23T11:03:33Z")

</div>

I do not understand the meaning of the variable. What exactly are you trying to do?

---

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [August 23, 2020, 8:16pm UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/7 "2020-08-23T20:16:50Z")

</div>

I am calculating how long my gate has been open. Set the variable to one when opened, and increment after a delay of 60 secs (which can easily be changed) when the value changes. If the value equals 3 I send an alert to my phone. If still open after the value equals 5 I send another alert. If I leave the gate open inadvertently (which I sometimes do when I get distracted) I want to be notified so my pets can’t get out.

---

<div class="post-metadata">

### Author: ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)
#### Post date: [August 24, 2020, 4:14am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/8 "2020-08-24T04:14:26Z")

</div>

Okay, got it. That’s why I wrote about it in the previous post.  
But for the process to work there are still missing more cards and flows. But I guess you know that yourself.  
But in this case you don’t need a numeric variable. You can also realize this only with timer.

---

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [August 24, 2020, 4:46am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/9 "2020-08-24T04:46:59Z")

</div>

OK, where do I find the Timer? I haven’t found one.

---

<div class="post-metadata">

### Author: ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)
#### Post date: [August 24, 2020, 5:41am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/10 "2020-08-24T05:41:03Z")

</div>

There are different Timer Apps:  
Timer  
Countdown timer  
Countdown  
Chronograph  
Which app you use is more or less irrelevant for your case. The apps differ slightly in their functions.

The CountDown app is supposed to be the only app that continues running after a homey restart. Furthermore, the CountDown App is currently still being maintained. That’s why I might prefer this one.

---

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [August 25, 2020, 1:37am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/11 "2020-08-25T01:37:34Z")

</div>

Thanks for the info. I have downloaded the App and tried to set it up but I must be doing something wrong. It doesn’t look like the timer is starting.

 ![Screen Shot 2020-08-25 at 11.32.48 am](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/c/9c79f0654c1c0094e266b3e03cdafe93204476d1.png) ![Screen Shot 2020-08-25 at 11.33.18 am](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/d/1d899a5e3302043293f4945459202b7314b894a5.png) ![Screen Shot 2020-08-25 at 11.33.37 am](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/9/39a3ab4a3eaa4f0bfb6b52fed5f1b89d197a513a.png)

---

<div class="post-metadata">

### Author: ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)
#### Post date: [August 25, 2020, 5:15am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/12 "2020-08-25T05:15:14Z")

</div>

But u do get the message from the first flow?  
The 2nd and 3th flow u need to adjust with something like:  
WHEN (countdown) timer value has changed AND (countdown) Countdown is exact 45 AND contactalarm is on THEN (mobile) send message.

WHEN (countdown) timer reaches zero (0) AND contactalarm is on THEN (mobile) send message.

---

<div class="post-metadata">

### Author: ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)
#### Post date: [August 25, 2020, 5:40am UTC](https://community.homey.app/t/gate-open-timer-incrementing-logic-variables/33821/13 "2020-08-25T05:40:59Z")

</div>

Fantastic. It is now working perfectly. Thanks very much.
