# The order of cards executed in flows

**URL:** <https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877>\
**Category:** Flows\
**Created:** [June 30, 2020, 8:12pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877 "2020-06-30T20:12:45Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [June 30, 2020, 8:12pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/1 "2020-06-30T20:12:45Z")

</div>

Hello,  
I’ve got a problem I can’t find a solution for. Let’s start with an example to explain the problem.

I’ve got a light device (just an on/off property). I’d like to have a flow executed only if the light has been switched on outside of a Homey flow (e.g. with a light switch in the wall connected with this device).

To achieve this I:

1. Prepare a Boolean variable auto\_turn\_on = false
2. Create first flow (named X):  
a. WHEN this light turns ON  
b. AND auto\_turn\_on = false  
c. THEN send me a notification
3. I create the second flow (named Y):  
a. WHEN this flow is started  
b. AND this light is OFF  
c. THEN:  
i) auto\_turn\_on = true  
II) turn on this light  
iii) auto\_turn\_on = false with delay e.g. 3 seconds

If the cards would be executed in this order, then eveytime I run flow Y, flow X shouldn’t send me a notification. The notification should be only executed if the light has been turned on outside flow Y. But it looks like it’s different. Sometimes I do get a notification after I execute flow Y. It looks like the light is turned on before the variable is set to true. Is there any possibility to be sure in which order the cards are executed? Or any other idea how to achieve what I try to do (execute some action only if the device state was not changed by another flow)?

Piotr

---

<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:** [June 30, 2020, 8:37pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/2 "2020-06-30T20:37:42Z")

</div>

> [@Piotr\_Grochowski](#):
>
> i) auto\_turn\_on = true  
> II) turn on this light  
> iii) auto\_turn\_on = false with delay e.g. 3 seconds

First: What does trigger WHEN this flow is started?

Second add a delay for 1 sec at ii) turn on this light. Now i) and ii) are executed at the same time which can cause problems for correct executing

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [June 30, 2020, 8:51pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/3 "2020-06-30T20:51:55Z")

</div>

Dear Marcel,  
“this flow is started” is used in WHEN for Flows that are not triggered by devices, but that are either executed by another flow (with a card Start a flow) or manually.

Reg. delay in turning on the light - it’s not the case. The light has to be turned on immediately (e.g. after a motion sensor detects motion or a contact sensor is open). So I can’t add delay. There has to be any other solution.

Piotr

---

<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:** [July 1, 2020, 5:56am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/4 "2020-07-01T05:56:27Z")

</div>

> [@Piotr\_Grochowski](#):
>
> I’d like to have a flow executed only if the light has been switched on outside of a Homey flow (e.g. with a light switch in the wall connected with this device).

Is this a smart switch or a dumb switch?

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [July 1, 2020, 8:32am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/5 "2020-07-01T08:32:03Z")

</div>

It’s a smart switch (BleBox switchBox). It can be switched by Homey, or by pressing the physical switch on the wall. In both cases the same trigger is fired in Homey Flow, so I was searching for a method to determine if it was switched physically or by Homey flow (by using a variable as above)…

---

<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:** [July 1, 2020, 10:19am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/6 "2020-07-01T10:19:10Z")

</div>

Can’y you make another flow with the switch. With my switches i gave the options, when a button is pushed and when a scenario us triggered for button 1. Do you have sone options for tour switch?

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [July 1, 2020, 10:32am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/7 "2020-07-01T10:32:14Z")

</div>

I’d like to have separate flows, but how may one determine if the device state was changed to ON by pressing the physical button or by Homey? In both cases there is the same trigger fired by Homey.

Piotr

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [July 1, 2020, 3:38pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/9 "2020-07-01T15:38:19Z")

</div>

> [@Piotr\_Grochowski](#):
>
> i) auto\_turn\_on = true  
> II) turn on this light

Put a 1 second delay on

> II) turn on this light

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [July 2, 2020, 7:14am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/10 "2020-07-02T07:14:05Z")

</div>

JPe4619 - no, the delay is not acceptable in the scenario. The light has to switch on immediately.

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [July 2, 2020, 7:14am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/11 "2020-07-02T07:14:55Z")

</div>

Thenks Roy  
That’s a good idea! Just to change the variable value and make a flow with a trigger on that variable! I’ll try that, but logically thinking it should work as I need!

Piotr

---

<div class="post-metadata">

**Author:** ![Marius\_Kohmann](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marius_kohmann/32/32319_2.png) [@Marius\_Kohmann](https://community.homey.app/u/Marius_Kohmann)\
**Post date:** [April 3, 2021, 10:18pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/12 "2021-04-03T22:18:13Z")

</div>

Did this work out? I am trying to achieve the same when I want to implement manual override in my automations.

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [April 4, 2021, 7:47am UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/13 "2021-04-04T07:47:23Z")

</div>

The Action cards are executed asynchronously so no guarantee which will happen first. The only option in that situation is the delay if you want to determine the order.  
Have you looked at the H.O.O.P app in the community store?  
That allows you to add Action cards to the conditions section where they happen sequentially.

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [April 4, 2021, 12:00pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/14 "2021-04-04T12:00:37Z")

</div>

No, I totally changed the idea of my Flows, because all the flows and action cards are executed asynchronously.

---

<div class="post-metadata">

**Author:** ![Piotr\_Grochowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/piotr_grochowski/32/9530_2.png) [@Piotr\_Grochowski](https://community.homey.app/u/Piotr_Grochowski)\
**Post date:** [April 4, 2021, 12:01pm UTC](https://community.homey.app/t/the-order-of-cards-executed-in-flows/31877/15 "2021-04-04T12:01:49Z")

</div>

I’ll check the H.O.O.P, thanks.
