# Problem with numeric variables counting

**URL:** <https://community.homey.app/t/problem-with-numeric-variables-counting/23902>\
**Category:** Flows\
**Created:** [January 6, 2020, 11:16am UTC](https://community.homey.app/t/problem-with-numeric-variables-counting/23902 "2020-01-06T11:16:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carnage](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carnage](https://community.homey.app/u/Carnage)\
**Post date:** [January 6, 2020, 11:16am UTC](https://community.homey.app/t/problem-with-numeric-variables-counting/23902/1 "2020-01-06T11:16:52Z")

</div>

Hello everyone,

I got my Homey pro a few days ago, and my first Logic problem.

I have numeric variable that starts at 0 and should count +1 every time the “else” condition is met… so I made {{var+1}} problem is, it does not stop counting… ever…

Details:  
It’s for my nuki lock. I want it to check if my door is closed every minute and then close it

if  
motion detector is off  
and var = \>0  
and door is closed  
then  
lock door  
set var to 0  
else  
var={{var+1}}  
start the same flow again  
(the I have another flow, that notifies me if var is above 10)

in theory, it should work, but the counting does not stop after one count it just continues…  
Is there a solution? Thank you. 🙂

---

<div class="post-metadata">

**Author:** ![Osorkon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/osorkon/32/43026_2.png) [@Osorkon](https://community.homey.app/u/Osorkon)\
**Post date:** [January 6, 2020, 11:28am UTC](https://community.homey.app/t/problem-with-numeric-variables-counting/23902/2 "2020-01-06T11:28:23Z")

</div>

> [@Carnage](#):
>
> work, but the counting does not stop after one count it just continues…

It’s logical! Take a look at you flow!

> [@Carnage](#):
>
> if  
> motion detector is off  
> and var = \>0  
> and door is closed  
> then  
> lock door  
> set var to 0  
> else  
> var={{var+1}}  
> start the same flow again

Especially the last line!

I think you want only count + 1 after a motion was detected and goes off.

---

<div class="post-metadata">

**Author:** ![Carnage](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carnage](https://community.homey.app/u/Carnage)\
**Post date:** [January 6, 2020, 11:35am UTC](https://community.homey.app/t/problem-with-numeric-variables-counting/23902/3 "2020-01-06T11:35:44Z")

</div>

> [@Osorkon](#):
>
> I think you want only count + 1 after a motion was detected and goes off.

the else condition is a count… but I do not think that the flow is the problem, the flow works… the problem is, as far as I see it, that the logic card just keeps counting, if you count with the same var and not just once…

the flow loops only if the door is not locked and stays open.  
It stops looping when the door is closed… but the var does not stop counting because it tries to finish it  
In the test modus it never gets a green checkmark… it just continues.

Edit:  
Okay, I take it back… It is the flow… but I don’t see what I have done wrong lol

---

<div class="post-metadata">

**Author:** ![Osorkon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/osorkon/32/43026_2.png) [@Osorkon](https://community.homey.app/u/Osorkon)\
**Post date:** [January 6, 2020, 12:00pm UTC](https://community.homey.app/t/problem-with-numeric-variables-counting/23902/4 "2020-01-06T12:00:36Z")

</div>

If you var =\>O  
and your door is Open  
Then the else will be executed.  
With the Aktion

> [@Carnage](#):
>
> start the same flow again

you create a loop.
