Homey Community Forum

How to structure your flows

The kitchen lighting is a virtual device too, but in this case a switch. This way homey knows if the lights are switched on. I use this status in other flows (ea motion triggered in the garden switches the lights on and off. But the kitchen should not go off when they are turned on)

Also notice I have 2 virtual devices (switch) that represent a status. Based on the a scene is selected. (During cleaning and diner the light should be more bright

image

image

image

3 Likes
  • the scenes flow
    These flows actualy set the light to a desired setting

image

image

image

2 Likes

Yes it is a lot of flows. But homey is not bothered by a lot of flows. And the flows are simple, no complex AND / OR.

Advantage:

  • You can easily change your dayly routines. Just change the time trigger in this one flow and all the rest is unchanged.

  • Its easier to group flows in folders named after the zones in the flow section. Makes it easy to find flows

  • it makes adding a flow easier: When I create a new flow that should start when I go to bed. I only need to create that flow. No need to also update the trigger flow that starts at bedtime with a “start a flow card”

  • it makes you more flexible: bedtime can be different per day. So I will have multiple trigger flows for time (tag: @). When I use “start a flow”, in case of creating a new flow I would need to add that flow to every trigger flow defining bedtime.

  • Easily trigger multiple action flows with one trigger. Without the flows becoming complex. The living, kitchen and hall are nicely separated.

  • Because flows are split, you can use the AND column in both flows. This gives more options and makes it better readable, less complex. As you see in the flows, every room has its own lux measurement in the AND, All triggered by one timer flow.

If I want the coffeemachine to heat up, I just create an extra flow with the same virtaul device as a trigger

If I want the kitchen lights to turn on later… I just change the WHEN to an other virtual device that is linked to a different time trigger.

2 Likes

How to structure flows: reduce number of flows by using variables
Sometimes exactly the same flows are used, only with different values. Just to set different situation/scenes
You can simplify this by using variables and just one basic flow.

Example:

  • the lights in my kitchen are controlled by a lux measurement.
  • but I have different situation,these require different lux to trigger: at dinner I want the light to go on a little sooner. During cleaning I really want more light, so the lights should stay on even longer

What did is:
I have one flow triggering the lights based on lux measurement.
“KK is donker lux” is the variable controlling the switching
“Helderheid” is the homey tag for the lux measurement of the hue motion sensor
image
image
image

In logic I created several variables that I use only to define lux Pre-sets (desired lux levels for switching)
(You can use a value in the flow instead of these presets, but I prefer to use variables because these are easier to update and can be re-used in other flows)
image

Now I can control the lux level that the light switch on.
What I do is set the value of the variable “KK is donker lux” with logic command to one of the predefined values.
So during the day I change the value “KK is donker lux”
When I get up:
image
image

When diner starts:
image
image

Notice: I am using the virtual devices to trigger flows as described above…

How to structure flows: prepare your flows for debugging

Bugs and strange behaviour, it will always happen.
So you better be prepared…
Structuring your flows makes it easier to find bugs, but you need a start for your bug search

  1. Make sure every When section in your flows has a logging point
  2. If you use an and also make sure to add a logging point in the Else section. Especially if your Else section does not have any cards! (How else can you determine if the flow triggered and hit the Else or did not trigger at all)
  3. If you add a (long) delay, make sure to also add a logging point with that same delay. (After 1hr switch off the light, how will you ever trace that one if you do not log)
  1. In case of bugs, run flow viewer
  2. Use the web browser to print to pdf
  3. Open the file in a pdf viewer that support searching
  4. Now you can search for the logging text or a device

How to structure flows: Add comments to your flows
Splitting up flows can also be confusing sometimes.
For better understand and for refernece you can add comment to a flow.

I created an app that allows you to add comment.
Find the app description here
And the app here

image

Thanks for this guide. I have not yet found a system I am happy with, so will definitely consider this when I decide to reorganize my 150 flows for the 4th time.

I use almost an identical structure. it does, however, require some discipline. Some flows are fairly simple (if movement, then switch con one light) so it is tempting to just make one flow for it. Instead, the structure requires to cut up also these simple flows in two. Feels a bit like adding complexity, but it does help a lot in circumstances where unintentional or unforseen actions happen that could be triggered by several trigger-events. In these cases It took less time to identify the responsible trigger and tweak it.

3 Likes

I added another section with new tips atthe top…:

I lost you a bit at the logic part. What did you do with all the different values?
I like your flow attitude. I’ll see how I’ll work with it :slight_smile:

1 Like

Thanks for your feedback.
I tried to clarify it a bit (old text in italic)

Some flows are copied to set different situation/scenes.

Sometimes exactly the same flows are used, only with different values. Just to set different situation/scenes

Added:
“Helderheid” is the homey tag for the lux measurement of the hue motion sensor

In logic I created several lux settings:

In logic I created several variables that I use only to define lux Pre-sets (desired lux levels for switching)

(You can use the value in the flow instead of these presets, but I prefer to use variables because these are easier to update and can be re-used in other flows)

Now I can control the lux level that the light switch on.

  • What I do is change the value of the variable “KK is donker lux” with logic command.*

So during the day I change the that value:

Now I can control the lux level that the light switch on.

What I do is set the value of the variable “KK is donker lux” with logic command to one of the predefined values.

So during the day I change the value “KK is donker lux”

aaah, KK is donker is the minimum value when the lights don’t need to turn on.
After that they turn on, I see. And at different moments (opstaan 9wakeup) etc you set a different required “helderheid” from the motion sensor? Right?

How would you turn on " eten"’ eg?

That is correct. And I change this value based on the situation.
The cleaninglady needs more light so I change the value to turn the lights on earlier

Nope, “helderheid” is the value that is measured by the motionsensor (tag).
This value is compared to “KK is donker”

The value “KK is donker” is changed at different moments during the day, matching the need.

ah, checked.
And the need changes via one of the buttons or voice commands, or time of day right?

I use time of day.
But you can use any trigger to start a flow that set the value of “KK is donker”

Okay, I’ll start working with that! :slight_smile:

Added a new section at the top:

1 Like

Thank you for sharing your work. Could you post a screenshot from the flow.homey.app web gui with expanded folders please? This would be very helpful for me to understand your approach, rebuild my structure and clean up my mess :blush:

2 Likes

Thank you :+1: :grinning: