[HOW TO] Alternative approach to structure and organise your flows

Like many, I have a lot of flows now (229 of them, to be precise). I have tried a few different ways to structure and organise them since I migrated from Indigo to Homey about a year ago. For a long while I used the system described here How to structure your flows and it worked OK but I personally found it too cumbersome to maintain. I liked a lot of the ideas and principles but adding devices to enable strict separation of trigger and action flows, while a great idea, just didn’t work for me in practice. I found it would still take me ages to trace through chains of flows to find and fix faults. Also, I ended up with a tonne of devices and that cluttered up the device views making it hard to find what I was looking for. It’s also really user-unfriendly if you have other family members using the Homey app since they also get to see all your “inner workings” devices whether they want to or not.

So I came up with a new approach which is a lot simpler and which, having converted everything to it and lived with it for ~3 months now, I am really pleased with. So here it is:

Key points

  • Flows are organised into folders (and, where necessary, sub-folders) based on the type of actions they do - such as: lighting, heating, security, presence etc.
  • Each flow does one type of action (which obviously determines which folder/sub-folder it goes into).
  • Each flow is named primarily according to the action it does and sometimes secondarily the trigger, where this is needed to disambiguate from another flow (e.g. “Bathroom fan on when humidity rises”, “Bathroom fan off when humidity falls”, “Log bathroom humidity change”, “Lights for day mode”)

The point about each flow doing only one type of action is the key here. Since we only have a folder hierarchy rather than tags for flows, we need each flow to belong logically to exactly one folder/sub-folder. Using the actions as the basis for organisation, the folder tree is based around action types and so each flow needs to do exactly one action type.

I have found that, for me, it’s the exception rather than the norm that I want one trigger to trigger more than one type of action (I often have more than one action of course, but generally all of the same type). For the exceptions, I simply duplicate the flow and put actions of one type in each ‘copy’ of the flow (with the same WHEN and AND cards in each). An example is my morning wake up alarm where I want to control the lights and the radio. One flow for all the lights control and one for the radio - with the same trigger (my wake up alarm in Homey) and conditions. These are filed accordingly into their respective places in the folder tree (“Lighting / Upstairs” and “Radios”, respectively).

Other top tips

  • While you’re organising your flows, take the opportunity to add logging to EVERY SINGLE ONE. I use the Simple LOG app and the last action card in every single flow is a Simple LOG card
  • To make this easier and more consistent, I use the “Add Something to a log group” card from Simple LOG and set the group name to the name of the folder the flow is in, showing sub-folders like this “Lighting / downstairs”. For the log entry itself, I simply use the name of the flow. This way, I can always see the exact sequence in which flows are triggering when I look at the log and if I need to go and change one, the log tells me where in the flow folder tree to find that flow.
  • When using ELSE branches in the THEN section, I add a log card to each ELSE branch and append a logical description of which branch to the log - like this “Record bathroom light level (BRIGHT)”, “Record bathroom light level (DARK)”. This way, I can also tell from the log which branch of each flow was actually executed.

This helps to make up for Homey’s lack of a general-purpose log and makes fault-finding enormously easier. By looking through the logs I have several times found faults I didn’t even realise I had simply by spotting that I had flows triggering far more often than I intended (which was causing issues by clogging up the z-wave network with duplicate commands and slowing down other commands). When you have issues to track down later, you will thank your past self for making sure every single flow creates a clear and consistent log entry.

Why organise around actions rather than triggers?

My reasoning was that I wanted to make fault-finding and maintenance easier. Generally when I go fault finding it is because something either happened that I wasn’t expecting or didn’t happen that I was expecting. For the latter case (something didn’t happen that I was expecting), I generally go through the flow folder tree to find it - e.g. “why did the upstairs hall light not come on when I walked into the upstairs hall and it was dark?” → go look in the “Lighting / upstairs” folder for a flow called something like “Upstairs hall light on with motion”. Then if I can’t see the issue immediately, go look in the logs to find out whether the flow executed, which branch, which other flows executed before it if they were meant to set the conditions etc.

For the former case (something happened that I didn’t expect), I generally go looking in the logs for the thing that happened at about the right time. For example “why did the upstairs hall light come on when I walked into the upstairs hall but it was light?” → go look at the logs for an entry at about the right time called something like “Upstairs hall light on with motion”. If I can’t remember the exact time and I need to browse through a lot of logs, export them to CSV and then use a spreadsheet to filter only the log entries with the group “Lighting / upstairs lights”.

In both situations, I want the flows and log entries to be named and organised based on the action.

I hope this is useful for someone. Very interested to hear other experiences / approaches with this same issue.

10 Likes

@Jonathan_Draper

Nice idea and great that you took the time to motivate and explain your flow structuring.

To get a better understanding, how would you arrange flows that are related to presence?

In my case, if a family member leaves, a brunch of flows can get triggered. Lights, blinds, hifi, heating, curtains. Is this trigger flow copied to various folders (lights, heating, hifi, blinds et cetera)?

Thank you @Eternity

Yes like you I have a few scenarios when multiple types of thing get controlled. Last person leaving is a good example. And yes it’s as you say, I create a flow for each type of item and file it accordingly. Of course you can choose how granular you make the list of ‘types’ to help manage the complexity.

When I started I went really granular but realised after a while this made for unnecessary complexity and in fact I could get away with fewer types. I ended up with my ~230 flows fitting into 8 top level types (which are folders in the flows tab). I do use sub types (sub folders in flows tab) within those to help organise so that I only have to look through 10-15 flows in a list when searching for something. One practice I developed and have ended up liking enough to stick with is when I have a situation where I’m controlling a bunch of items in the same top level type but split across several sub types I just create one flow rather than several and file it directly in the top level folder for that type. So in your example you might have a top level folder for windows with sub folders for blinds and curtains. Then you might have a flow triggered by last person out at night which closes all the blinds and curtains and file that flow in the windows top level folder. Of course this is only useful if you also have several other flows that are specific to blinds and curtains respectively. Otherwise you’d just have one folder for windows and be done.

1 Like

Hi,
I am just starting off with honey. So I am diving in finding the best ways to set it up.
I am familiar with programming so I should have no issue setting up in advanced mode with flows, triggers etc, I believe :grin:

Anyway I came across your post of setting things up. And your way seems most compelling.
Since it has been some time I was wondering if you are still sticking to this method and if you have any tweaks.
Perhaps you can share some screenshots on your folders structure and names used (Dutch as well, so I should understand that).

Thanks for the insight
Jeroen

Hi @JeroenIam welcome aboard! I think you’ll like it here!

This is a great question and I have been meaning to come back and update this topic for a while so a good prompt.

The system I now use is still pretty much identical to what I describe above, with one key change. That change was brought about with the introduction of advanced flows, which arrived after I set out this system. When I got playing with those I realised that as well as enabling you to do more advanced things with each flow, they also enabled all the pieces of logic relating to one ‘thing’ to be collected on a single canvas in one advanced flow (since you can have as many completely separate sets of trigger / conditions / action logic cards in a single advanced flow). This makes the flows a LOT easier to manage since there are fewer of them in the list, with simpler names and you can see all the related parts of the logic for a single thing together.

You can almost think of each advanced flow as an ‘object’ with ‘methods’ and you can even call those methods from other flows if you want using the start flow with text tag card like this:

So now my system is organised into folders based on the type of thing they do, exactly as described above. But now instead of needing lots of separate flows all relating to the same ‘thing’ like:

  • kitchen lights on when X happens
  • kitchen lights on when Y happens
  • kitchen lights off when Z happens etc.

… now I instead have a single flow called ‘Kitchen lights’ which contains all of those bits of logic together. So a small part of my folder structure for flows looks like this:

(You can see I still haven’t got round to converting all the simple flows into advanced ones.) And my advanced flows tend to end up looking like this:

You can see I’m still using the Simple LOG app extensively for logging. Also, I tend to arrange the separate flows in ‘rows’ down the canvas, with notes cards indicating what each chunk of the logic relates to.

I hope this helps as you set off on your Homey journey. Enjoy the ride!

2 Likes

@Jonathan_Draper Great work and tips! And kudos on beautiful layout, nice!

One tip on using cards with The flow is started with a Text-tag:

  1. If you have many simultaneous triggers with these cards (eg motion), it can become CPU heavy and cause delayed response. I felt I had to reduce these calls, especially those that test for the Text-tag to “contain” a certain text.
  2. Have a look at the big brother of calling flows: Advanced Triggers. A bit more complicated, but very nice to ensure sequential finishing an action before the next action or skipping too many of the same actions following a (motion) trigger. It managed to reduce my peak system load significantly (120%->30%) doing unneeded stuff.

One trick with Syslog I think you may already be using, it is to set Severity and use that to limit your notifications to say Whatsapp or Telegram to track what’s happening. I do not like so much scanning through Syslogs, but the notifications are a great way to track.

1 Like

Thanks for further explaining. Makes sense to use the advanced flows, I only know advanced. :slight_smile:

Thanks will dive in.

Interesting point about the CPU use.
Can you maybe post some screenshots what your flows/with triggers look like.

Thanks
J

Here is a flow that sets a wait of 120000 ms (2 min) before it accepts a next motion. It debounces (skips) any motion that comes in the meanwhile).

I needed this especially when walking through the house and one after the other motion sensor started triggering actions (which they should once, but not more).

In this example, there is only one action (turn on lights) so there is little gain. But in reality I have multiple conditions before turning on the light, like if it is dark and if the door is open etc

You can use the AT fields to pass a text/number/YesNo: like the name of the motion sensor, illumination number or a boolean if it is dark. These values stay in the queue so you know that these were valid from the moment the new event was placed in the queue. This can work in your favor or not.

2 Likes

Here is another Advanced Trigger I use for sending messages to various apps (Telegram, Whatsapp) with additional conditions.

It is sequential so it skips none, but waits until the (shortest) branch has finished.

image

2 Likes

Thanks, I will dive in as soon as I have more time. House is almost done, then the fun bit will start.

Thanks Again
J