# Set var twice only triggers one follow-on action?

**URL:** <https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114>\
**Category:** Questions & Help\
**Tags:** advancedflow\
**Created:** [September 9, 2023, 10:09pm UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114 "2023-09-09T22:09:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DirkdeDraak](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkdedraak/32/8620_2.png) [@DirkdeDraak](https://community.homey.app/u/DirkdeDraak)\
**Post date:** [September 9, 2023, 10:09pm UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/1 "2023-09-09T22:09:42Z")

</div>

I had some issues with my “how many family members are home” (advanced) flow.  
Many times it somehow miscounted although I was quite sure I had done everything to avoid miscounts.  
I have a single advanced flow that has multiple triggers points.  
Example:

1. Person X goes away =\> subtract 1 from numberOfResidentsAtHome
2. If numberOfResidentsAtHome changed =\> subtract 1 from numberOfPeopleAthome  
Where it seemed to go wrong was when two people left the house at the same time, then it seemed to miscount (or don’t trigger twice)

I then focused on how and when my variables are set/changed and found the following.

 ![homey_set_var_twice_fail](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/4/94b559c9eb3e6264bc016d1ce58607d66de0691d.png)  
Here the variable TestLogicVar is set twice (at least that is what I think should happen). I would expect it to then also create two separate triggers.

When I change the wait time between one and the other set, it works fine.

 ![homey_set_var_twice_ok](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/6/b6efcb8e220a5a8ff41aec3ae769e2fc19b97a96.png)

Can someone confirm that they experience the same?  
If so, would you agree that I may expect the first example to work?

---

<div class="post-metadata">

**Author:** ![Wim\_Post](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wim_post/32/56793_2.png) [@Wim\_Post](https://community.homey.app/u/Wim_Post)\
**Post date:** [September 10, 2023, 4:34pm UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/2 "2023-09-10T16:34:59Z")

</div>

In the first screenprint you are trying to change the same logic-card at the same time.  
In other words should n’t the second logic-card be ‘…….2’?

---

<div class="post-metadata">

**Author:** ![DirkdeDraak](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkdedraak/32/8620_2.png) [@DirkdeDraak](https://community.homey.app/u/DirkdeDraak)\
**Post date:** [September 10, 2023, 5:41pm UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/3 "2023-09-10T17:41:08Z")

</div>

Thanks Wim, though no, this is exactly what I’m trying to do.

I’m trying to show that if you change a (the same) variable twice in a timeframe that’s very close, it doesn’t trigger twice.  
If you add a delay of 1 second it does trigger twice.  
To me that’s not correct. It should trigger twice as you make 2 changes.

This is the code that started my problem search… I now added 3 delays, all 1 second apart.  
Without the delay and if two people left at the same time and somehow both triggered this flow at the same time (?) it only triggered once at time.

 ![homey_x_left](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/9/1968e7bb6947eb91f0204e81c43904813a7de2c8.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 11, 2023, 10:37am UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/4 "2023-09-11T10:37:07Z")

</div>

> [@DirkdeDraak](#):
>
> ![homey_set_var_twice_fail](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/4/94b559c9eb3e6264bc016d1ce58607d66de0691d.png)
> 
> expect it to then also create two separate triggers.

No, while you connected them in **parallel** → it’s supposed to be set at the same time!

**Connect them in series** , and they will be set one after the other, and there will be 2 separate triggers with two different var values

 ![Screenshot from 2023-09-11 12-34-19](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/c/3c916e929a8b1cc13a218983a96d98c94117c8d0.png)

Simple Log, note the just slightly different timestamps:

> ![Screenshot from 2023-09-11 12-32-33](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/4/1490cba28b266e1cf21624f3a1902ee5b5c8aada.png)

---

<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:** [September 12, 2023, 7:43am UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/5 "2023-09-12T07:43:13Z")

</div>

> [@DirkdeDraak](#):
>
> Without the delay and if two people left at the same time and somehow both triggered this flow at the same time (?) it only triggered once at time.

Did you only simulate the flow, or does the problem also occur in real life?  
Because my wife and I often left the house together and go away together in the same car. Since 2019 it has never happened that the status “Has gone” was set at the exactly same time.

---

<div class="post-metadata">

**Author:** ![DirkdeDraak](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkdedraak/32/8620_2.png) [@DirkdeDraak](https://community.homey.app/u/DirkdeDraak)\
**Post date:** [September 12, 2023, 5:44pm UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/6 "2023-09-12T17:44:31Z")

</div>

Thanks Peter, you showed it works like that.  
Partially I agree that having those two set commands are in parallel and suppose to happen at the same time, but still I think of them being two separate actions. Apparently not, so I’ll adjust my flow to make them happen in sequence.

---

<div class="post-metadata">

**Author:** ![DirkdeDraak](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkdedraak/32/8620_2.png) [@DirkdeDraak](https://community.homey.app/u/DirkdeDraak)\
**Post date:** [September 12, 2023, 5:46pm UTC](https://community.homey.app/t/set-var-twice-only-triggers-one-follow-on-action/89114/7 "2023-09-12T17:46:28Z")

</div>

I had it in real life.  
We are at home with 3, at time my “PeopleHome” counter was -1 other times it was 4.  
So either fired double or not as many times as I would expect.

With a forced wait that is different for each event it seems to solidly stay within the zero to 3 range.
