Homey Community Forum

Tutorial - Advanced automatic light control with flows

Nice tutorial! But I’m curious why you use virtual switches right in the flows and not virtual buttons with a variable? Now when you set a scene, you have to switch off all other scenes (virtual switches) in that flow.

For example:

  • You create 3 virtual buttons: normal, movie, candle
  • You create 1 variable: scene status
  • Then you create 3 flows. The only thing that those flows do is setting the variable ‘scene status’ to ‘normal’, ‘movie’ or ‘candle’.
  • Then you have you have 3 flows to set the lights. These flows are triggered by the variable that is changed. Like this for the ‘normal scene’: 'when logic ‘scene status’ is changed, and ‘scene status’ = ‘normal’ than dim lights to…

Now you never have to switch off the other scenes, becaus the variable ‘scene status’ can only have 1 vallue.

1 Like

That’s another way to do it and was actually similar to my previous implementation. However, I prefer switches over buttons because I can see which scene is active by looking at the devices, since the inactive scenes are grayed out. This is not the case when using buttons. It also makes it more intuitive when displayed in a dashboard in my opinion.


Yeah that’s a good reason to do it like that. And I also found out that triggering on a variable isn’t working good: Triggeren op veranderen variabel 'logica' naar bepaalde waarde werkt niet goed (Dutch)…

Nice tutorial!

One question:
Why do you check for dark in your action flow BR_ac_LightsOn? The check for dark is already done in movement flow BR_ev_Motion_on_dark. Or keep the check and rename the on motion event to a general event, not just during dark.

regards from one who tries to understand :wink:


That’s actually a very good question. One of them is redundant and can be removed. I would remove the one from BR_ac_LightsOn. This way, you can still add this flow to your favourites, allowing you to quickly turn all the lights on whenever you want to :).

Thank you.

One more:
When you change scenes, the lights turns on even though no one is in the room. Right? I’ve added a check for activity in the room to prevent this. Am I missing something here?


Yes you are correct. I have ‘solved’ this by not turning on the lights when it’s between 13:59 and 14:01 (i know, hacky). I like your solution better!

1 Like

In the flow “lights on”, I get an error “token out of range”, when try do dim lights from the variable I made. However, if the lights are already on it seems to work. What am I doing wrong?

dim value is in percentage, so 0.00 - 1.00, so if your own made variable is using numerical 0 - 100 then it will not work.

Yep, that’s it. Thank you! :slight_smile:

Works fine with Hue lights, but looks like turning off Fibaro dimmer sets dim lvl to 0…

Yup that is the downside of z-wave (not just fibaro), the dim level == on/off state, 0 is off, anything higher is on, there is no different command/thing/information for just the on/off state

Okay, did not know that. So I guess I have to used fixed value on those…

Did not discover your tuturial until now (someone responded to it making it come up)
Nice to see how you structured you flows almost exactly the way I do.
See my post about how to structure flows

I do this too, but use some more categories (and different tags)

Also defining scenes and using virtual devices too :slightly_smiling_face:

And check on that too (using papertrails for it…)

Did not use this yet, but I do like the idea and flow

1 Like

Nice man thanks

I don’t quite get the momory function. What do you use this for?

This is used if you manually overwrite your light configuration. Image you have set the brightness of your lights to 100% via the wall switch, if you wouldn’t have the memory function, it would reset it to the value configured in Homey when it detects movement.

1 Like

Hmm. And what if I want a certain value to be set when motion is detected, except when the light has been set manually? Would I still nee the memory.

Second question is, 60 seconds on motion in a room timer is short isn’t it? For me they turn off very quickly eg when I’m reading.

@Marvin_Schenkel I think you made a typo in your flow.
The name of the variable you check is “BR_darklight” the name of the variable you set is “BR_lightdark”


This is exactly what the memory function + reset flows are used for. Whenever you manually set the brightness via a physical switch, it will update the variable with the brightness and will use that brightness value from then on. In my reset flows, I reset that variable back to it’s default value, so my preconfigured values are used again the night after.

60 seconds is a bit low when you’re reading in the bedroom. I’ve got it set to 15 minutes in the living room, but feel free to tune the variables to your liking :slight_smile: . That’s why I chose to use variables, so it’s easy to tweak :wink: .

Good find. I think it used to be called BR_LightDark and the name just got stuck in the flows after I had renamed my variable :wink: .