# Flow using door sensor to turn on lights, then back off

**URL:** <https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839>\
**Category:** Questions & Help\
**Tags:** zigbee, flow\
**Created:** [August 26, 2021, 11:14am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839 "2021-08-26T11:14:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpcams](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpcams/32/41095_2.png) [@jpcams](https://community.homey.app/u/jpcams)\
**Post date:** [August 26, 2021, 11:14am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/1 "2021-08-26T11:14:22Z")

</div>

I have an Aqara Zigbee door sensor on a storage closet under the stairs that turns the light on upon opening the door. It also turns the light off when the door is closed. However, I would like to have the light turn off if the door is left open, after 7 minutes.

Can I do this within the same flow or should this be handled separately? Not sure exactly how to connect the duration to an off card.

---

<div class="post-metadata">

**Author:** ![Homey-Cornelisse](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/homey-cornelisse/32/147927_2.png) [@Homey-Cornelisse](https://community.homey.app/u/Homey-Cornelisse)\
**Post date:** [August 26, 2021, 11:29am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/2 "2021-08-26T11:29:07Z")

</div>

it should work like this [Shared Flow | Homey](https://homey.app/f/rxHd2K)

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [August 26, 2021, 11:37am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/3 "2021-08-26T11:37:14Z")

</div>

No, this means that the light will be turned off 7 Minutes after the door is closed.

@jpcams wants to turn off the light if the door stays more than 7 minutes open, right?

It’s possible with the same flow:

 ![Bildschirmfoto 2021-08-26 um 13.32.28](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/c/8cae790a484ddf47555ecd4fc17004048b2cce81.png)

---

<div class="post-metadata">

**Author:** ![Arnold\_vd\_Linden](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arnold_vd_linden/32/19336_2.png) [@Arnold\_vd\_Linden](https://community.homey.app/u/Arnold_vd_Linden)\
**Post date:** [August 26, 2021, 5:13pm UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/4 "2021-08-26T17:13:32Z")

</div>

Something like this?

[https://homey.app/f/-LPs3K](https://homey.app/f/-LPs3K)

And to turn it off when the door closed you make a new flow that triggers de alarm off state of the door sensor.

---

<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:** [August 26, 2021, 6:04pm UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/5 "2021-08-26T18:04:13Z")

</div>

On the surface this will work, except for one caveat. In the scenario that you open the door, close it, and 6 mins later you open the door again, in this setup I am not sure what the delay of the first trigger does. Might be it sends the off signal within the minute, and again after 7 mins.

Therefore I use Homey delays only for the short and simple ones, and use an app like [[App] Chronograph - Adds precise timer, stopwatch and transition functionality to Homey](https://community.homey.app/t/app-chronograph-adds-precise-timer-stopwatch-and-transition-functionality-to-homey/18214) or similar to start actual timers.

Using that you can start the timer when the door opens, and cancel it when you close the door. That way you are sure you won’t be surprised by inexplicable events caused by hidden delays.

With hidden delays I mean that in normal Homey delay operation you cannot see that an action is pending. With the above app you can see any running timers in the app configuration page, so you can see what is going on and debugging is way easier.

---

<div class="post-metadata">

**Author:** ![Arnold\_vd\_Linden](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arnold_vd_linden/32/19336_2.png) [@Arnold\_vd\_Linden](https://community.homey.app/u/Arnold_vd_Linden)\
**Post date:** [August 26, 2021, 7:27pm UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/6 "2021-08-26T19:27:45Z")

</div>

> [@Edwin\_D](#):
>
> Might be it sends the off signal within the minute, and again after 7 mins.

In my case case the first timer is deleted or something. I tried it earlier.

---

<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:** [August 26, 2021, 8:36pm UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/7 "2021-08-26T20:36:31Z")

</div>

In that case you should be fine. If you ever find yourself in a situation with more complex needs: the app also supports things like resetting timers, less than second timers, checking if timers are running, starting a new timer if there isn’t one and keeping it as it if its already running, changing a value gradually over time, measuring time and much more.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [August 27, 2021, 9:50am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/8 "2021-08-27T09:50:17Z")

</div>

> [@Edwin\_D](#):
>
> In the scenario that you open the door, close it, and 6 mins later you open the door again, in this setup I am not sure what the delay of the first trigger does.

@Edwin_D, you’re absolutely right. The delay doesn’t stopp. So in this example the light turns off after 1 Minute, if the door is opened the second time after 6 min (within in the delay time) again.  
Don’t know if this behavior depends on the used app, but I guess not. I used the Fibaro app resp. Fibaro devices.  
One way the flows might look:

**Flow 1 (Open door)**  
When…  
– The contact alarm has been activated  
Then…  
– Turn on light  
– Start Timer “Storeroom” with a duration of 7 min

**Flow 2 (Close door)**  
When…  
– The contact alarm has gone off  
Then…  
– Turn off light  
– Stop Timer “Storeroom”

**Flow 3 (Door stays open)**  
When…  
– Timer “Storeroom” expired  
Then…  
– Turn off light

@jpcams, for this scenario you need a timer app. There are several apps in the app store, so it’s your choice. I use the Chronograph app, as Edwin already suggested.

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [August 27, 2021, 11:32pm UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/9 "2021-08-27T23:32:30Z")

</div>

And for the fun.

**Flow 4 (Door closed after timer expired)**

When…  
– The contact alarm gone off

And…  
– The light is off

Then…  
– Speach (Let Homey say something) for example: You forgot to close the door again

---

<div class="post-metadata">

**Author:** ![jpcams](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpcams/32/41095_2.png) [@jpcams](https://community.homey.app/u/jpcams)\
**Post date:** [August 28, 2021, 9:09pm UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/10 "2021-08-28T21:09:14Z")

</div>

That was it exactly! Thanks for helping me out. Now I will think about other things that I can connect with a timer.

Is there a topic already started where people talk about flows they use, especially flows more complex? I would be curious how I can strengthen my existing setup.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [August 29, 2021, 7:16am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/11 "2021-08-29T07:16:42Z")

</div>

There is a thread category called [Tutorials](https://community.homey.app/c/tutorials/83) with some interesting flows. Also you can search for „DIY“, „Tutorial“ and „How to“, because not all tutorials are in this category.  
But there are a lot of more interesting tutorials in the „Flows“ category, for example from @Justin.

---

<div class="post-metadata">

**Author:** ![Ralf\_Groot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ralf_groot/32/16474_2.png) [@Ralf\_Groot](https://community.homey.app/u/Ralf_Groot)\
**Post date:** [September 2, 2021, 9:50am UTC](https://community.homey.app/t/flow-using-door-sensor-to-turn-on-lights-then-back-off/50839/12 "2021-09-02T09:50:59Z")

</div>

I did it with two flows using the timer app.  
First flow: Door open, start timer for xx seconds (timer will switch on the light and switch it off after xx seconds/minutes/hours)

Second flow: Door close, cancel timer and switch off light
