Door open/close sensor

I have a door open/close sensor on a door and I’m trying to put a light on the first time I open the door. After that I close the door and the light have to keep on. After the second time I open/close the door I want the light off and I want this only when it is dark. Can somebody help me with this pls.

@jos11 Hi, first you need to have the lights enabled on your hub, either via HA, a third-party device connected via ZigBee, or via Matter. As for your question, it’s pretty easy. You’ll simply need to create two different automations. The first one turns on the light, for example, “IF the door sensor is open or close, THEN the kitchen light turns on.” For the second, you should have a brightness sensor among your devices that allows you to turn the light off when it’s dark. Or you can do it via two specific schedules.

Please note that with an Aqara app, you cannot create a condition for automation where the door is both open and closed in the same automation. This is not currently allowed. So I recommend creating your automation like this: “IF the door is closed since xx.xx hours” and the brightness is below xx lux, THEN turn off the light.

1 Like

@gtxteo thank you for the reply. I have a Aqara M3 hub and the light is just a normal bulb but triggered by a Aqara switch H2 EU via Matter. I try it in the way you explained it to me. I will let you know the result later this day :slightly_smiling_face:

@jos11 Perfect, I’m waiting for your reply. I hope it works. I also have an M3 Hub with about 100 animations. :rofl:

1 Like

Hello, I just checked your automation on version 2.0.
It works.
The algorithm for turning on “IF” the door is open (period 10 s)->door is closed (period 10 s) “AND” the lamp is off “THEN” turn on the lamp (period at sunset-sunrise).
The algorithm for turning off (I additionally use a motion sensor in the room). “IF” there is movement (period 10 s)->door is open (period 10 s)->door is closed (period 10 s) “AND” the lamp is on “THEN” turn off the lamp.
The automation is made in Aqara home. I additionally use a motion sensor.
For information - 2.0 will be released in the near future.

2 Likes

Hi @gtxteo at this moment I still can’t get it working but if I find a work around I will let you know. @gafich10 said that it will work on version 2.0 maybe I have to wait for that. I don’t have a motion sensor at that place and I don’t want that for certain reasons. but still thanks for the input.

@gafich10 Thank you for the info. :+1: T hen I have to wait at version 2.0
I hope it will be released soon.

@gtxteo and @gafich10 I found a way at this moment.
If: Open door sensor
Then: Turn on/off - Switch Door
When you first open the door the light goes on and the second time you open the door the light turns off.
I noticed that when I do that with “at sunset” it doesn’t work.
So now the light is going on and of 24/7 but I will search further if I can find a solution for that.

1 Like

@jos11 I don’t have access to version 2.0 yet, but if @gafich10 confirms it works, then you can bet on it. Try to find the solution that best suits your needs. If you need help, just ask.

1 Like

Hehe @gafich10 It seems that the motion sensor was not in the request, but with it it is certainly easier to do it.

1 Like

By the way, everything works without a motion sensor!
I just used it because I have it. I just didn’t think that it was possible to automate without a motion sensor until @Raman.V suggested it in the comment. :slightly_smiling_face:

2 Likes

@gafich10 @Raman.V @gtxteo Thank you all. Maybe someone can explain to me why it doesn’t work with “Then: after sunset on/off” because I was thinking that it would be the same as “Then: Door switch on/off”.

Give me a screenshot of the automation screen

1 Like


These are the two automations
The first one works.

Translation: keuken- kitchen / Balkon- Balcony

@gtxteo, @gafich10 and @Raman.V
I found the automations that i needed. So now everything is working as it should be. It was a combination of the two automations.

1 Like

Top. Enjoy @jos11

1 Like

@gtxteo Thanks for your help :+1:

No problem. Happy to help.

1 Like

That’s right, you often need to use double, triple conditions.
Just for information - (°} instant action, (°°) permanent state. Maybe you know this.
Also for information - now the day/night state is local, tied to the location of the gateway in the area.

1 Like

@gafich10 thanks for the info and the help.

2 Likes