Homey Community Forum

[HOWTO] Create a flow that turns lights on dimmed while you sleep (and bright in day time) using motion

I always used Hue’s schedule options to turn lights on with the motion sensor. I had a schedule between 23:00 and 7:00 that turned the lights dimmed. That works pretty good, but when you’re not a regular sleeper between 23:00 and 7:00 lights may be dimmed when you don’t want to or are bright as hell when you were sleeping. So I created flows that take the default status of Sleep/Awake in consideration.

You have a motion sensor on a light in let’s say the toilet. You want it bright when you are awake, but you want it on dimmed when you need to go in the middle of the night. More important: you do not want time to control this. When you head to bed early it needs to dim early and the other way around for when you are making things late!

You need a room with motion detection (or something to make the room active, like a door sensor) and a connected light.
We also need a countdown app, like CountDown App voor Homey | Homey

Not really in this tutorial but very important: think about what makes you sleep. You can use all sorts of things for this. I am using a series of things that make me probably asleep: the lights in the living room are off, and between certain times my nightstand light goes out. Take in consideration that this time needs to cover an early night and one in the middle of the night (coming home from a party or something).

Also, in addition to every persons sleep/awake status, I use a general variable to mark us both as sleeping. And I use this in flows. This could be different for you. And things get complicated when different persons go to bed on different times.

Let’s get started!

We use a few variables and a count down timer to guide things the right way.

  1. Count down timer for the room Motion: Toilet.
    The count down timer is the period of time the lights will be on if there is no activation.

  2. Variable Slapen we? (or Asleep?), boolean, set it to false.

We make 2 flows when the room gets active, one for day time and one for the night.

Uploading: Schermafbeelding 2022-01-06 om 11.18.34.png…

How does this flow work?

  • Trigger in both flows is the activation of the room, in my case a motion sensor.
  • The flow continues when the variable gives the right value (we are sleeping/we are not sleeping). You could merge these two flows in one using ELSE, but I like it this way.
  • Both flows turn on the light (for sleeping: the night scene, for awake: the day scene). And both flows stop the count down timer.

We make a flow that keeps the lights on for a little while when there is no motion.

How does this flow work?

  • The flow is triggered if there is no motion.
  • It turns on a count down timer for 180 seconds.

Do you want a different grace time for nighttime?

  • Make two flows for this step.
  • Add the IF statement from step 2 in this step.
  • Change the duration of the countdown timers for day and night.

We make a simple flow that turns of the lights when the countdown timer reaches zero.

How does this flow work?

  • The flow is triggered when the countdown timer is 0. That means that there was no motion in the grace period.
  • The light is turned off.
1 Like