# Conditional flow

**URL:** <https://community.homey.app/t/conditional-flow/21391>\
**Category:** Questions & Help\
**Created:** [November 27, 2019, 7:58am UTC](https://community.homey.app/t/conditional-flow/21391 "2019-11-27T07:58:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [November 27, 2019, 7:58am UTC](https://community.homey.app/t/conditional-flow/21391/1 "2019-11-27T07:58:20Z")

</div>

Could someone help me out with the following?

In some of my flows I set a variable in order to be able to revert back to previous state. This is meant to be used for temporary states, like the one set by my “Watch TV” flow. I don’t want normal lighting when watching TV. I will also use it for stuff like changing from daytime lighting to nighttime lighting.

Is there some way to make a flow do the following?  
If laststate=x then xfunc  
Else if laststate=y then yfunc  
Else if laststate=y then zfunc

It would also be awesome if there was a way to handle inline code (or script the whole flow), to do stuff like “if light\_source.ison() then …” to dim lights that are on without turning on lights that have been turned manually off (for å reason).

Thanks!

---

<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:** [November 27, 2019, 9:03am UTC](https://community.homey.app/t/conditional-flow/21391/2 "2019-11-27T09:03:36Z")

</div>

If you have set the state in a variable you can do this, but not in 1 flow. I have a example flow where the variable can be 1-7. Flows are WHEN variable changed AND variable is 1, THEN do this, ELSE start flow 2. WHEN this flow is started, AND variable is 2, THEN do this, ELSE start flow 3. Etc etc

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [November 27, 2019, 9:35am UTC](https://community.homey.app/t/conditional-flow/21391/3 "2019-11-27T09:35:57Z")

</div>

That’s what I’m afraid of. At the moment, the only solution I can see is to create a bunch of isPrevStateX, then if previous state was x, the run flowX and empty the variable. Then create a “master flow” called RevertToPreviousState and start all of these isPrevStateX flows. It’s just incredibly ineffective and it really hurts my ego.developer 😛

---

<div class="post-metadata">

**Author:** ![aeonax](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aeonax/32/14285_2.png) [@aeonax](https://community.homey.app/u/aeonax)\
**Post date:** [November 27, 2019, 1:08pm UTC](https://community.homey.app/t/conditional-flow/21391/4 "2019-11-27T13:08:30Z")

</div>

Maybe with Homey script? Haven’t used that yet but I think it should be able to do advanced variable tasks? Within the app, multiple flows are unfortunately unavoidable for more than two conditions.

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [November 27, 2019, 4:27pm UTC](https://community.homey.app/t/conditional-flow/21391/5 "2019-11-27T16:27:57Z")

</div>

Hmmm…hadn’t even heard about it. Will check it out. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Jan\_Willem\_Visser](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_willem_visser/32/10747_2.png) [@Jan\_Willem\_Visser](https://community.homey.app/u/Jan_Willem_Visser)\
**Post date:** [November 27, 2019, 6:45pm UTC](https://community.homey.app/t/conditional-flow/21391/6 "2019-11-27T18:45:41Z")

</div>

I have made 3 flows. The first called “avond”(evening), thats the normal state of light. When the tv is going on a flow started called “TV light”. And when i watch a movie i push a button on my dashboard or press a widget on my phone to start the “movie light” flow to set the lights for watching a movie.

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [November 27, 2019, 8:00pm UTC](https://community.homey.app/t/conditional-flow/21391/7 "2019-11-27T20:00:28Z")

</div>

That’s the low tech version and how I have it now (except for automatically running the TV light when turning the TV on) - I want to automate it.

---

<div class="post-metadata">

**Author:** ![Jan\_Willem\_Visser](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_willem_visser/32/10747_2.png) [@Jan\_Willem\_Visser](https://community.homey.app/u/Jan_Willem_Visser)\
**Post date:** [November 27, 2019, 8:10pm UTC](https://community.homey.app/t/conditional-flow/21391/8 "2019-11-27T20:10:07Z")

</div>

Everything going automatically, when the tv going on the lights go to tv mode, when tv going off the lights going back to evening mode. When i push te "movie light"button te lights going to movie mode en when i push the button again the lights going back to normal evening mode.

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [November 27, 2019, 8:46pm UTC](https://community.homey.app/t/conditional-flow/21391/9 "2019-11-27T20:46:42Z")

</div>

Ok, then I misunderstood. However, I would like them to go back to the previous mode - not necessarily evening mode.
