Homey Community Forum

Conditional flow

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!

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

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 :stuck_out_tongue:

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.

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

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.

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.

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.

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