# Tutorial - Advanced automatic light control with flows

**URL:** <https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877>\
**Category:** Tutorials\
**Tags:** tutorial, flow\
**Created:** [December 4, 2019, 10:31am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877 "2019-12-04T10:31:47Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [April 13, 2020, 6:43pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/21 "2020-04-13T18:43:23Z")

</div>

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](https://community.homey.app/t/how-to-structure-your-flows/25109/3)

> [@Marvin\_Schenkel](#):
>
> I divide my flows into two categories: events (ev) and actions (ac)

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

> [@Marvin\_Schenkel](#):
>
> I use scenes to set my lights to a specific ‘mood’ that’s appropriate for that time \<…\> We will be using ‘Virtual switches’ to define our scenes

Also defining scenes and using virtual devices too 🙂

> [@Marvin\_Schenkel](#):
>
> (Optional) [The simple log app](https://homey.app/nl-nl/app/nl.nielsdeklerk.log/Simple-LOG/) by Niels de Klerk to log which flows are executed. This is optional, but I like this app because it gives me an overview of everything that is happening in my apartment and makes it easy to debug any issues I come across

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

> [@Marvin\_Schenkel](#):
>
> Memory function for the brightness of our lights

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

---

<div class="post-metadata">

**Author:** ![Jort\_Van\_der\_molen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jort_van_der_molen/32/16472_2.png) [@Jort\_Van\_der\_molen](https://community.homey.app/u/Jort_Van_der_molen)\
**Post date:** [April 29, 2020, 7:49pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/22 "2020-04-29T19:49:33Z")

</div>

Nice man thanks

---

<div class="post-metadata">

**Author:** ![victoroos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/victoroos/32/8344_2.png) [@victoroos](https://community.homey.app/u/victoroos)\
**Post date:** [May 29, 2020, 7:41am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/25 "2020-05-29T07:41:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marvin\_Schenkel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marvin_schenkel/32/10195_2.png) [@Marvin\_Schenkel](https://community.homey.app/u/Marvin_Schenkel)\
**Post date:** [May 29, 2020, 11:17am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/26 "2020-05-29T11:17:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![victoroos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/victoroos/32/8344_2.png) [@victoroos](https://community.homey.app/u/victoroos)\
**Post date:** [May 30, 2020, 10:37pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/27 "2020-05-30T22:37:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [May 31, 2020, 6:06am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/28 "2020-05-31T06:06:11Z")

</div>

> [@Marvin\_Schenkel](#):
>
> Note how I verify whether the variable isn’t already set to dark in order to prevent this flow from firing over and over again.

@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”

---

<div class="post-metadata">

**Author:** ![Marvin\_Schenkel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marvin_schenkel/32/10195_2.png) [@Marvin\_Schenkel](https://community.homey.app/u/Marvin_Schenkel)\
**Post date:** [June 1, 2020, 9:12am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/29 "2020-06-01T09:12:30Z")

</div>

@victoroos

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 🙂 . That’s why I chose to use variables, so it’s easy to tweak 😉 .

---

<div class="post-metadata">

**Author:** ![Marvin\_Schenkel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marvin_schenkel/32/10195_2.png) [@Marvin\_Schenkel](https://community.homey.app/u/Marvin_Schenkel)\
**Post date:** [June 1, 2020, 9:14am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/30 "2020-06-01T09:14:31Z")

</div>

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 😉 .

---

<div class="post-metadata">

**Author:** ![Simon\_Skotheimsvik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/simon_skotheimsvik/32/34205_2.png) [@Simon\_Skotheimsvik](https://community.homey.app/u/Simon_Skotheimsvik)\
**Post date:** [January 17, 2021, 7:45pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/31 "2021-01-17T19:45:53Z")

</div>

Nice article - Thanks for sharing!  
How do you track if people in the house hold is at sleep or awake (or at home or away)?

---

<div class="post-metadata">

**Author:** ![RobMen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robmen/32/34411_2.png) [@RobMen](https://community.homey.app/u/RobMen)\
**Post date:** [February 7, 2021, 7:22pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/32 "2021-02-07T19:22:17Z")

</div>

Great flow, this is what i`m looking for years. I have a few questions:

- How do you do the presence check that one of you is sleeping?
- When I test the BR\_ev\_LumChanged\_Dark it gives an error at the logic part BR\_DarkLight is not exactly dark… I don`t know where that is coming from?
- I m using the hue motion sensor which also has the Lux sensor in it. But when I create the flow the flow will be inactive. I don`t know why.
- Your memory function is great, but it is a lot of work when I want do that with all the lights, is somethign also possible with the hue scene`s?

---

<div class="post-metadata">

**Author:** ![Marvin\_Schenkel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marvin_schenkel/32/10195_2.png) [@Marvin\_Schenkel](https://community.homey.app/u/Marvin_Schenkel)\
**Post date:** [February 8, 2021, 7:42am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/33 "2021-02-08T07:42:37Z")

</div>

- I use a flic button (but you can use any smart button) to mark myself as asleep/awake,. You can also buy products like [Under-mattress sleep tracker - Sleep Analyzer | Withings](https://www.withings.com/eu/en/sleep-analyzer) or even DIY one: [Building a bed occupancy sensor for Home Assistant - Everything Smart Home](https://everythingsmarthome.co.uk/howto/building-a-bed-occupancy-sensor-for-home-assistant/)
- It is probably because you have not provided a value for the variable ‘BR\_DarkLight’ before hitting ‘test’. Before testing a flow, you have to provide values for any variables that are used in the flow
- I would need a bit more context before I can help you out with the lux sensor 😉
- It sure is a lot of work, but it does allow granular control over your lights. It is definitely possible to stick to the Hue scenes, but I don’t really see how that would help with the memory functions. A nice ‘middle way’ is disabling the automatic light flows whenever manual control is used. That way you do not have to store the brightness in variables, but can still override the programmed values for your lights. Then you can use a timer to re-enable automatic lights when you please.

---

<div class="post-metadata">

**Author:** ![RobMen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robmen/32/34411_2.png) [@RobMen](https://community.homey.app/u/RobMen)\
**Post date:** [February 8, 2021, 10:03am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/34 "2021-02-08T10:03:28Z")

</div>

Hi Marvin, thanks for your reply.

1. Yes the button that’s simple and good idea.

2. See my screenshots. I do not know what I`m doing wrong. [Wk\_ev\_LumChanged\_Dark|333x500](https://community.homey.app/uploads/short-url/3JtIvHNmMNhpcv4xn1qWTNGm4Kk.png)  
[Logic|690x490](https://community.homey.app/uploads/short-url/psRFtTua4Hs18g3XanucHwTApe5.jpeg)

3. The flows with Lum sensor are inactive.  
[Flow\_inactive\_with\_Lum\_sensor|602x500](https://community.homey.app/uploads/short-url/qkKOoYjNGeMZUWh5TmaDWkgVK8W.jpeg) Does the motion sensor needs to be configured in the hue app? Now it is also already detecting motion and its working.

4. Great idea.

---

<div class="post-metadata">

**Author:** ![Marvin\_Schenkel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marvin_schenkel/32/10195_2.png) [@Marvin\_Schenkel](https://community.homey.app/u/Marvin_Schenkel)\
**Post date:** [February 8, 2021, 10:46am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/35 "2021-02-08T10:46:33Z")

</div>

1. You probably need to supply a value for ‘Helderheid’ in order to test your flow. I wouldn’t worry too much about it, this flow looks fine and should work as expected
2. Your flow is not disabled. The grayed-out icon means you just cannot run this flow on demand (by pressing the icon). This is usually the case for flows the trigger based on events that supply data that is used in the flow (e.g. the ‘Helderheid’ in your case). Flows that just ‘do stuff’ without using data from the event can be manually triggered :).

---

<div class="post-metadata">

**Author:** ![milkplus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/milkplus/32/35755_2.png) [@milkplus](https://community.homey.app/u/milkplus)\
**Post date:** [April 21, 2021, 2:30pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/36 "2021-04-21T14:30:07Z")

</div>

Just wanted to say that this is a really fantastic tutorial! Have set it up this afternoon for my living room and entrance way, now just waiting for it to start getting darker to see it in action. Thanks for spelling everything out so clearly, it’s super appreciated!

---

<div class="post-metadata">

**Author:** ![milkplus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/milkplus/32/35755_2.png) [@milkplus](https://community.homey.app/u/milkplus)\
**Post date:** [April 22, 2021, 4:02pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/37 "2021-04-22T16:02:52Z")

</div>

Hi there. Little bit of an update. I added a (THEN) ‘Stop Countdown’ step in the BR\_ev\_Motion\_on\_dark flow as I kept finding that my lights would randomly (or not randomly, but actually when the timer hits zero) go out and leave me in the dark. Think it’s because my Light/motion sensors (Develco) don’t detect lux/motion nearly often enough. Will see if this step helps keep the lights on, literally 😉

Also, I’m trying to wrap my brain around how to make it so that in my Kitchen, when lux is between two values (i.e. 40 & 100) then only one of my four lights (kitchen bench) comes on. Then, once lux drops below 40, it reverts back to all lights. Will this require new flows and additional variables? Or is there some way to strong-arm it in somewhere? I’m new to Homey so all the flows and variable can get a bit overwhelming 😅

---

<div class="post-metadata">

**Author:** ![Felix\_oslo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/felix_oslo/32/33969_2.png) [@Felix\_oslo](https://community.homey.app/u/Felix_oslo)\
**Post date:** [August 31, 2021, 10:44pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/38 "2021-08-31T22:44:26Z")

</div>

There is a problem with Fibaro Dimmer 2. When turning off, the Dim\_Level is set to zero. Any idea on how this can be resolved? The result is that the light doesn’t turn on again since the parameter is set to zero.

---

<div class="post-metadata">

**Author:** ![Martijn\_Hoogenbosch](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martijn_hoogenbosch/32/10647_2.png) [@Martijn\_Hoogenbosch](https://community.homey.app/u/Martijn_Hoogenbosch)\
**Post date:** [September 1, 2021, 3:54am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/39 "2021-09-01T03:54:13Z")

</div>

Can’t say I have the same thing. Turning off just turns off.

---

<div class="post-metadata">

**Author:** ![Felix\_oslo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/felix_oslo/32/33969_2.png) [@Felix\_oslo](https://community.homey.app/u/Felix_oslo)\
**Post date:** [September 1, 2021, 6:45am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/40 "2021-09-01T06:45:21Z")

</div>

It it’s with Fibaro Dimmer 2, it sounds like you either have an error in the settings, or in the Flow. Try reset the Dimmer 2, I had an issue that was similar, and used the dimmer from an old Smartthings config. Resetting the dimmer, solved it. But the problem with Dimmer 2 is still that turning it off, sets the dimming to zero

---

<div class="post-metadata">

**Author:** ![Marvin\_Schenkel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marvin_schenkel/32/10195_2.png) [@Marvin\_Schenkel](https://community.homey.app/u/Marvin_Schenkel)\
**Post date:** [September 1, 2021, 8:07am UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/41 "2021-09-01T08:07:53Z")

</div>

Maybe you can use an extra condition in your flows that set the brightness:

- Light is on
- or [Leve] is not equal to 0

This way the brightness is only saved when the light is on.

---

<div class="post-metadata">

**Author:** ![Felix\_oslo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/felix_oslo/32/33969_2.png) [@Felix\_oslo](https://community.homey.app/u/Felix_oslo)\
**Post date:** [September 3, 2021, 5:13pm UTC](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877/42 "2021-09-03T17:13:55Z")

</div>

The problem is that Fibaro sets the DimLevel to zero when it turns off. I can’t see how your rule will help in any way? Maybe you can avoid storing the DimLevel when turning off somehow, but I can’t figure out how.

[Previous page](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877.md?page=1)

[Next page](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877.md?page=3)
