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

**URL:** <https://community.homey.app/t/tutorial-simple-movement-triggered-automatic-light-with-zone-activity-cards-just-2-flows/39651>\
**Category:** Tutorials\
**Created:** [December 23, 2020, 8:55am UTC](https://community.homey.app/t/tutorial-simple-movement-triggered-automatic-light-with-zone-activity-cards-just-2-flows/39651 "2020-12-23T08:55:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RogerSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rogerst/32/12432_2.png) [@RogerSt](https://community.homey.app/u/RogerSt)\
**Post date:** [December 23, 2020, 8:55am UTC](https://community.homey.app/t/tutorial-simple-movement-triggered-automatic-light-with-zone-activity-cards-just-2-flows/39651/1 "2020-12-23T08:55:10Z")

</div>

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:

- [Tutorial - Advanced automatic light control with flows](https://community.homey.app/t/tutorial-advanced-automatic-light-control-with-flows/21877)
- [[Simple] Lights turning on/off based on motion - #33 by EvR](https://community.homey.app/t/simple-lights-turning-on-off-based-on-motion/10889/33)

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… 😛

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](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/e/9e77c74eb1ed9fa182ad3bf34af78e875c85114d.png)

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](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/e/6e75786b7d29bf69632278e2f248aa9845cadcec.png)

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](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/7/171133125d11dbf2d748dda6d80e00660149b43c.png)

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](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/e/6eb2bd774aeacf65645861c4056424bc84238f3f.png)

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

Hope this sharing helps 🙂 All the best!

---

<div class="post-metadata">

**Author:** ![Edwin\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/edwin_d/32/136417_2.png) [@Edwin\_D](https://community.homey.app/u/Edwin_D)\
**Post date:** [December 24, 2020, 2:14pm UTC](https://community.homey.app/t/tutorial-simple-movement-triggered-automatic-light-with-zone-activity-cards-just-2-flows/39651/2 "2020-12-24T14:14:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RogerSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rogerst/32/12432_2.png) [@RogerSt](https://community.homey.app/u/RogerSt)\
**Post date:** [December 24, 2020, 2:31pm UTC](https://community.homey.app/t/tutorial-simple-movement-triggered-automatic-light-with-zone-activity-cards-just-2-flows/39651/3 "2020-12-24T14:31:10Z")

</div>

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_
