# Homey Bridge: Turn on bedroom light with a motion sensor

**URL:** <https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860>\
**Category:** Questions & Help\
**Tags:** homey-bridge\
**Created:** [April 4, 2023, 9:33am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860 "2023-04-04T09:33:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 4, 2023, 9:33am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/1 "2023-04-04T09:33:08Z")

</div>

Hi guys.  
I am new to Homey Bridge, and have a problem. I want to be able to turn on one lamp in the bedroom when I need to go to the bathroom, should be working after 11PM and until sunrise, and then turn off again after there is no motion on the sensor.  
I am able to turn on the light with a flow, but when I add some extra conditions like the timing (11-sunrise), and turn off the light after no motion, nothing is working.  
Is there a clever one that can help me with making a flow for the Homey Bridge, please?  
Thank you very much in advance.

---

<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:** [April 4, 2023, 9:47am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/2 "2023-04-04T09:47:59Z")

</div>

Hi,  
please share your flow(s), maybe there is only a small mistake.

---

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 4, 2023, 10:12am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/4 "2023-04-04T10:12:29Z")

</div>

[https://homey.app/f/lRaMbt/](https://homey.app/f/lRaMbt/)

This time in english language.

---

<div class="post-metadata">

**Author:** ![Ria\_Banis](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ria_banis/32/7966_2.png) [@Ria\_Banis](https://community.homey.app/u/Ria_Banis)\
**Post date:** [April 4, 2023, 10:44am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/5 "2023-04-04T10:44:04Z")

</div>

Try it after you removed the else.

---

<div class="post-metadata">

**Author:** ![Thunder](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thunder/32/31836_2.png) [@Thunder](https://community.homey.app/u/Thunder)\
**Post date:** [April 4, 2023, 10:49am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/6 "2023-04-04T10:49:24Z")

</div>

What is turned on?

---

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 4, 2023, 11:35am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/7 "2023-04-04T11:35:32Z")

</div>

Only a bulb at first - normally just one lamp.

---

<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:** [April 4, 2023, 11:51am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/8 "2023-04-04T11:51:52Z")

</div>

As @Ria_Banis already suggested, remove the else part and create a second flow:

_ **When…** _  
– The motion alarm turned off

_ **And…** _  
– The bulb is turned on  
– The time is between **23:00** and **05:00**

_ **Then…** _  
– Turn off

You may run into another problem, and that is that the lamp keeps turning on and off. However, this depends on how the motion sensor works and/or is set up, as well as on the use case. If you run into this problem, let us know. Then we will find a better solution.

---

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 4, 2023, 12:14pm UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/9 "2023-04-04T12:14:04Z")

</div>

I tried that, and nothing is working. The motion sensor is Aqara Motion Sensor thru homey Aqara app, the lamp is Philips Hue thru Hue app on Homey.  
[https://homey.app/f/h8abct/](https://homey.app/f/h8abct/)  
[https://homey.app/f/NMcbct/](https://homey.app/f/NMcbct/)

So what is going wrong in this 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:** [April 4, 2023, 2:29pm UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/10 "2023-04-04T14:29:45Z")

</div>

Try  
— Time is **not** between **05:00** and **23:00**  
(Time from the original post)

---

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 4, 2023, 2:52pm UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/11 "2023-04-04T14:52:05Z")

</div>

I was happy .- for a minute 🙂 It worked when I reversed the time for both flows to be the reverse - but after it worked one time, it then stopped working again the 2nd time, I tried it. ☹

I put on another new Aqara M S to see if it was the sensor, but it is still the same: nothing happens.

---

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 4, 2023, 5:40pm UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/12 "2023-04-04T17:40:11Z")

</div>

I tested and tested, and came to this: When I press Test to test the first part, the lamp goes on, no matter if motion or not, and when I activate the M S, the 2nd part of it - flow 2, turns off the light when the sensor goes to idle - so - the last part seems to work, but not the first part.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 4, 2023, 8:56pm UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/13 "2023-04-04T20:56:09Z")

</div>

When you test a flow, you emulate the trigger, in this case the motion trigger. So it doesn’t matter if there’s no motion.  
It just tests the conditions and the actions of a flow.

I suggest to add timeline notifications to each Then and Else parts of the flows, then you can review what’s happening, and what’s not.

2nd flow:  
Why do you have a timeframe as condition to turn a light OFF? Now the light is _never switched off_ when the motion alarm turns off between 13:00h and 5:00h… But maybe that’s what you want?

Also, I’d remove the “and if light is turned on” condition.  
To me, it doesn´t matter to turn off a light which is off already.

And when it works, _then_ you can always add conditions, one by one.

---

<div class="post-metadata">

**Author:** ![Benny\_Mortensen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/benny_mortensen/32/72352_2.png) [@Benny\_Mortensen](https://community.homey.app/u/Benny_Mortensen)\
**Post date:** [April 5, 2023, 6:38am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/14 "2023-04-05T06:38:39Z")

</div>

Peter, the timeframe in 2nd flow was suggested earlier in the replies, thats why it was put in, to test it 🙂  
I decided to start all over again, removed everything, including the sensors, and restarted the Homey Bridge. Then I only added the sensor, and the lamp in the flow, and it worked. Then I added the time condition to the 1st flow, and now it works like a charm.  
Thank you for your suggestion about the timeline notifications, it was a perfect idea, that I didnt think of.  
Thanks to everyone being involved into this frustration  
😃

---

<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:** [April 5, 2023, 9:37am UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/15 "2023-04-05T09:37:30Z")

</div>

> [@Peter\_Kawa](#):
>
> Now the light is _never switched off_ when the motion alarm turns off between 13:00h and 5:00h… But maybe that’s what you want?

Right, it depends on what he wants to realize. And because he asked for flow during the night, I added the time flow-card also for turning off the light. Now, without the time flow-card, the flow runs always completely through including switching off the lamp, also between **05:00** and **23:00** when there is possible no need for that.  
And this is the straight way to the second point:

> [@Peter\_Kawa](#):
>
> Also, I’d remove the “and if light is turned on” condition.  
> To me, it doesn´t matter to turn off a light which is off already.

The flow-card “The bulb is turned on” prevents Homey to run the complete flow if the lamp isn’t switched on, or if the lamp was switched off manually in the meantime. I guess and hope, but this is my personally assumption, that this option saves Homey’s resources and saves unnecessary traffic.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 5, 2023, 4:18pm UTC](https://community.homey.app/t/homey-bridge-turn-on-bedroom-light-with-a-motion-sensor/78860/16 "2023-04-05T16:18:51Z")

</div>

Hi Dirk,

No worries, I just quickly looked at the two last shared flows and gave my thoughts on what could be the issue. I did not read everything written earlier.  
I did not know you suggested the timeframe in the ‘off’ flow, so nothing personal 🙃 I think otherwise I would have tagged you.

The second point is indeed how one looks at things, or how our Homey is running (white or redhot 😜 )  
That’s why I wrote, “to me it doesn’t matter to turn off a light which is off already”, but I meant of course:  
“to me it doesn’t matter to turn off a light which is off already **for this situation** ”

Why?  
A motion sensor is in general not sending alarm-OFF signals every 1 or 3 seconds, and does not cause a big load on Homey or the used protocol (in my eyes).  
When an _‘every 1 or 3 second trigger’_ is the case, I would also add a condition like “and light is off”.

Also, when troubleshooting, I think it’s a good idea to (temporary) remove anything I don’t need for the basic function of the flow.
