Homey Community Forum

[Tutorial] Simple movement-triggered automatic light with zone activity cards (just 2 flows!)

Hi everyone,

It’s time to share back what I learned here.

I have -in the past- tried several strategies to use lights that automatically trigger when movement is detected. Also, a lot has been written about this topic, for example:

and many more.

All of these either use

  • the CountDown App -or-
  • the Timer App

This allows for a lot of flexibility. But it can be tricky to configure. The best thing that worked for me is turning on the light when motion is detected, and when no more motion is detected, starting a timer to turn it off after a certain delay.

Been there, done that etc… However recently someone made me aware of the Zone Activity support of Homey, and the fact that it understands when “no activity has been detected in xxxx minutes”.

I have a use case in my ground floor hallway with 3 smart lights, 4 doors, and 3 motion sensors. No my house is not that big, I just have a lot of corners in my ground floor hallway… :stuck_out_tongue:

Here’s the user story:
AS A person
I WANT TO have the light switched on when movement is detected or if the door is opened, and automaticaly switched off after several minutes when movement is no longer detected and all doors are closed
SO I CAN have lights controlled automatically and power is saved when I am not around or forget to turn off the lights

All the doors, motion sensors and lights are in the same zone. As an extra requirement I want the ability to switch on/off the automatic behaviour; for example in case I need the light to stay on or off indefinitely.

For this to work, I started with a virtual device to control the automatic behaviour. I used a virtual device for this.
image

Next I created 2 flows to control the light.

The first flow turns the light on when activity (movement or door open) is detected in the zone:
image

As you can see, the flow respected the setting of the ‘autocontrol’ device. If that is off, the light will not turn on.

The second flow turns the light off after 5 minutes of inactivity (since all doors closed or movement):
image

With this approach, not all flexibility of the timer-/countdown-based flows can be achieved, but the amount of flows can be kept very low: Two flows: one for turning on, and one for turning off the lights.

In my example here I control an individual light, but it’s also possible to control all lights in a specific zone, so you don’t need to control each light individually.

That would look similar to:
image

Or you could use the < group > App and control certain device groups.

Hope this sharing helps :slight_smile: All the best!

4 Likes

Nice tutorial. If you do not want the virtual device, another approach to turn it on and off is to:

  1. disable the “light on” flow when you want it to stop
  2. check if the “light on” flow is enabled in the “light off” flow.
1 Like

Absolutely true.

Since I wanted the automatic control in my favourite devices list AND in my node-red dashboard, I opted for the virtual device.

So you could say I have added another user story which lead to me using the virtual device:

AS A resident of the house
USING node-red dashboard or a favourite device
I WANT TO switch the automatic light behaviour on and off with the touch of a button
SO I CAN choose to keep the light on or off, regardless of zone activity