How to turn on/off lights based on door sensor

Hi, I am attempting to set up an automated notification system for instances when my front door remains open for too long. Currently, I have a door sensor connected to an M3 hub, with Philips HUE lights integrated via Alexa. I have successfully started an Alexa routine that turns on the lights if the door stays open for more than two minutes; however, I have not been able to automate turning off the lights when the door is closed.

Ideally, I would like to avoid having the automation turn off the lights each time the door is closed in the evening, while the lights are otherwise in use.

Could you please advise on how best to configure this automation?

6 Likes

@PawelM Hi there! It sounds like you’re doing an excellent job getting your smart home set up. To achieve your goal of turning off the lights when the door is closed, while avoiding turning them off unnecessarily in the evening, you can try the following approach:

  1. Automation Setup: Since you are using a door sensor with an M3 hub, you can create a specific automation rule for your scenario. You need to ensure that the automation is activated only under the conditions you desire. For example, you can set up the automation to turn off the lights only if they were turned on by the same door sensor event.

  2. Using Time Conditions: To prevent the lights from turning off in the evening when they might be in use, you could add a time condition. This condition would check the time of day and only allow the automation to turn off the lights during specific hours when it’s more likely that the door closing should trigger the lights to turn off.

  3. Integration with Alexa: Since your Philips HUE lights are integrated via Alexa, you may be able to create or modify routines in the Alexa app to include additional conditions, such as the time of day or the state of other devices (like motion sensors) to control when the lights should turn off.

Unfortunately, the reference information doesn’t provide specific step-by-step instructions for integrating with Alexa, but community forums and the Alexa app itself can be great resources to explore further customization options.

If you need more detailed guidance, the community here can be a valuable source of tips and tricks. Feel free to share your progress or any additional questions you might have!

10 Likes

Setting these things up can be tricky…
First you need to decide… ā€˜what exactly do you want it to do?’
BUT start with the minimum to make it work and you can add conditions, or other triggers to it as you figure out what the total needs are.

2 Likes

Hello, in the Aqara 2.0 automation version, such a task is performed by one automation, I did it, tested it and checked it. If you don’t have access to it yet (active testing is underway), then you need to wait for its official launch. In version 1.0, you can also do it, but it will be a difficult task for a beginner. Note, I am writing about automation related only to Aqara home.

2 Likes

Hi, thank a lot. I’m not aware of 2.0 :frowning: do you know when it’s coming?

I know in HA you can capture a scene of how the lights were before the door was left opened and then you can recall that scene when the door is closed. That makes the lights go back to whatever state they were in before the automation was activated. Not sure if you can do this in the aqara app but it might be possible.

2 Likes

Hello, describe to me step by step what you want. Sequence algorithm, I will test and write back

1 Like

Thanks for help :slight_smile: This is what I want to do:

  1. Detect if my door is open longer then 2 minutes
  2. If true - turn my Philips HUE lamps red - BTW. Is it possible to activate scene?
  3. After closing door - switch light back to previous state
1 Like

I can imagine that. However I’m not using HA at least for now. Maybe in the future as I’ll get more experience.

Seguo

Hi, I’m not using any Google stuff and I don’t know Alexa’s capabilities, but in my ecosystem using Apple’s Shortcut built-in app it’s very easy. If you can write similar logic, than it should work.
-trigger: when front door open
-get variables of your bulb (like color, dim level, hue, saturation, whatever) by the time of door opened
-store the variables above
-run a repeat shortcut (2 min for eg. every 10 sec for 12 times)
-if door closed before 2 min expired: do nothing
-if door still open
-set your hue bulb color to red (scene also possible in Shortcuts)
-trigger: when front door closed
-set the stored variables to your bulb

Again, this is just to give a logic/idea to solve your automation wish.

Btw. you can create similar -true, not that complex- automation in HUE app. If you use Philips door contact sensor, it can trigger an automation. You should enable the Security Center in the app, than select a sensor to trigger an event. Create a Zone, which including the desired bulb to turn red only. Set the color and other characteristic if needed.

3 Likes

Hello. I made it on 1.0. 1 - if there is a light (turned on in the room) then someone is walking and working with the light, the door is open under human control, the red light is not on… 2- the light is off (conditionally there is no one) the door is open for 2 minutes, the red light is on (attention, the door is not closed). 3 - the door is closed, the light is off. The first automation turns on the second when there is a condition (the door is open, the light is not on). The second automation, the single-action mode is turned on, the door is closed - turn off the light. If I understood what you wanted correctly. Regarding your lamps, I do not know their settings in the automations.
It would be ideal if you had a motion sensor.
If you want some other option, write.



In the video, the sensor is set without delay (short video), you set it to 2 minutes and it will be the same.

1 Like

Hi, interesting to use Apple’s Shortcuts I’ve never used them so far except of very simple activities. How can you get variable of the bulb and make any condition check of the sensor?

Hi, so let’s do it from the basics.
-Add new automation (in Home App, not New Shortcut in the Shortcut app!)
-Select Events (A sensor detects something > select your door contact sensor) than Next
-Select the conditions (open/close) than Next
-Select accessories you wish to participate in your automation, than at the bottom of this page push ā€œConvert To Shortcutā€ (note: I’m on iOS 26 Beta 6, as far as I remember you should be on iOS 18.1 or later to have this ā€œConvert To Shortcutā€ option available)

The Shortcut itself to monitor your door open for 2 minutes. If your sensor close within the repeat cycle than nothing happen and shortcut stops. If not closed than your bulb will do what you set up to do.

2 Likes

If the light is normally on you could just program it to turn back to where you normally have it or maybe run some something like, if this light is on turn on ___ (some sort of switch or smart plug that you don’t really use) and then when the door is shut you can check if that plug or whatever is on and have that be the condition that tells it to turn the light back to where you usually have it.
It’s a little out there but it should work…

1 Like