Handling Else-If scenarios in flows

Hi everyone.
I know, that Homey do not support else if in flows so until they add that (fingers crossed) how do you handle this?

Being a developer im dying because of the missing else if possibilities so ill like to hear if you have any tips/suggestions how to work around this - without ending up with 1000 flows.

Sorry if this has been asked before, but i was not able to find and concrete in the forums.

Hi,

do you have an example of a flow you want to add which you can’t do right now? I’m a developer myself and yes it is sometimes a bit cumbersome (making 3 flows for something that seems to be able in 1 ) but most of the time I manage to do so.

At the moment it’s not that I’m not able to do what I want. But as you say it takes 3 or more flows for something that should/could be done in one.

So I just thought someone might have found the holy grail.

But a simple one could be reacting to a event with a value

When event SetLightMode
And EventValue == Normal
Then SetSomeLight
Else if EventValue == Dimmed
Then SetSomeOtherLight
Else if EventValue == Movie
Then SetSomeThirdLight

Unfortunatly that is not possible and I guess will never be. This is due to the target audience of Homey. It is, as far as I understand, aimed at casual customers. It’s not, like domoticz or something similar, aimed to tech people :wink:

http://homeyscript.athom.com/ for the more technical people :slight_smile:

I understand that they want to keep it simple for the “normal” user. But why not just add an “advanced” mode for the rest of us.
I know I havde done so many times in various projects.

I know about homeyscript, but the second I start doing that, I stop everyone else in the house from editing the flows - the can easily understand a basic if then else if then flow, but from there and a UI to homeyscript is a long, long way.

The best alternative you can have, not using Homeyscript, is to have multiple flows or use an app like https://apps.athom.com/app/name.klep.flow-event-bus.

I concluded that as well.

The eventbus is great but unfortunately you are not able to use the event values in neither the “and” or the “then”
And that is a damn shame :slightly_frowning_face:

Events are ephemeral, but you could look at using variables instead.

Yes and that is the problem.
As a developer I would expect to be able to handle the events payload.

Variables is a solution but honestly it sucks.

I’m a little bit late in this discussion, but I’m also a developer and I’m missing a bunch of features in Homey. Personally I think that an “if then else” would be a big advantage and if done right an easy to understand logic for causual users.

BUT, what I’m really missing and that’s a pain are two things.

1. A flow that han have "When → AND → AND NOT → Then
Why? Simple example. I have two windows in my kitchen and one thermostatic valve. I simply want to say: When window 1 closes and window 2 still open do nothing. When window 1 closes and window 2 closed set valve to heating. With the actual system, in the AND I have just the option “Window 2 is open” (no window 2 is closed) and that seems to be the same for most flows, the arguments in the AND do not show NOT values. So if the flow would accept AND NOT, I could at least place the “Window 2 is open” under it and it would do the job.
2. A presentation that shows flows as groups and indended if they are called in a flow. A clear presentation as in a programming language. That would not confuse causual users, but improve the readability.

Actually, I try to work around with variables like an open window counter in the kitchen. But this needs handling of the variables in the physically triggered flows and handling the second level by triggers on the variables. This is complicated compared to just an AND NOT card, makes everything unreadable and I have to document my flows to get an overview. The major downside of this is that after a restart of the homey, the variables may not reflect the truth (a window has been opened meanwhile).

Homey is either a very light solution for beginners with super limited possibilities, or a much to heavy solution by using script. An ELSE logic and a AND NOT section would make it usable for beginners, advanced users and programmers. It’s a shame that such a cool system is laking these features + weak z-Wave performance. Come on Homey, add a set of connectors to your sphere and offer external antennas on cables for Z-Wave and Zigbee as accessory to plug in (some users did the mod themselves - it’s nearly zero development) and add some features to your flow and you have THE ULTIMATE system on the market.

1 Like

What if something like this https://www.openplcproject.com would be integrated into Homey for the “professionals” ? Every problem concerning flows would be solved like timers, counters, arithmetic functions, complex programming constructions “if then else” constructors almost without boundaries, Modbus communications … using devices as actuators-sensors, having internal variables as markers. I know that IO and response times in Homey are on a different level then in a PLC but with a bit smart programming this issue can be solved if you ask me, you don’t need response times of milliseconds in a home automation system so slowing the PLC part down would be a double benefit because it would mean less CPU time and better synchronization between hard and software.
If this software had like MQTT capabilities I would have installed it on a Pi already, using Homey as a gateway by now. No flows, just apps for communicating with different devices and all logic running on the PLC part. Is there someone here that can have a look to see if this would be possible to integrate it into Homey?

Hi Pascal. I just stumbled on your post, I just wanted to respond.

Maybe I misunderstand, but this is pretty straightforward to build.

IF a contact alarm changed to state off
AND window1 contact is off
AND window2 contact is off
THEN switch heater ON
ELSE switch heater OFF

And, if window1 is opened, and window2 is closed or open or the other way round;
IF a contact alarm changed to state on
AND window1 contact is on
OR window2 contact is on
OR window1 contact is on
AND window2 contact is on
THEN switch heater OFF

+1 and I would like to add: some overview of which var is used in which flow(s).

I also want you and @lucje point to a neat flow editor app, which let you build flows way more flexible H.O.O.P. (Hope) - Homey Object Oriented Programming

Hi,

How do I setup the last part of this flow in the advanced flow?
It’s the “else” (ellers) at the bottom.

The last two cards is under the condition “Else”, but there is a second else between these two.
If all the conditions are set, the switch will turn on, else turn off.

Below SĂĄ
The top card is at the Then… part
The bottom card is in the Else… part.

It’s like
Then…
-turn light 1 on
and…
-turn light 2 on
Else…
-turn light 1 off
and…
-turn light 2 off

1 Like

Thank you!

So the plan is to turn the heater switch on if the price has changed & the current prices is right.
If not, then keep the switch off.

Will this be the same as I set up above?

YW and yes that’s correct!

I am trying to make an advanced flow for charging my car.

I want the else condition (charger off) to be set if either the time is not right or the price is too high.

But is it possible to get information about which of the 24 hours the car will charge ( 12 hours of the cheapest?
Like some kind of function, script or flow could check which hours is the cheapest and report back just for info.

It works like this, Kristian

1 Like

Thank you very much! :blush:

1 Like