Using Motion and Contact Sensors Together

How do most people here use their contact sensors in conjunction with motion sensors if at all?

I have been grappling with the concept in terms of bedroom lighting and the more I think about it and the more I implement, more and more edge cases come to mind and break my logic, which I fear is adding unnecessary complexity. So I wanted to step back and ask the community if they have any advice or tips for augmenting a motion lighting system with contact sensors, beyond the simple if open on, if closed off, the latter of which especially does not work with motion lighting systems in my experience.

Key issue I keep running into: working around sleep and if a person wants to sleep at an irregular time, the motion/contact lighting should not break in this scenario, i.e. turn on when it shouldn’t.

I have had this front of mind when I have setup my lighting rules, whether it was on my Hue bridge where there was only motion sensors, or on “any other hub…” where both contact and motion sensors were on offer. When I say that I mean the concept of edge cases has always been front of mind, and the tendency to think of neat sequences of triggers that would indicate presence or lack of it, but could easily be trumped in those edge cases.

While I don’t necessarily have a significantly irregular sleep situation myself, I don’t keep a particularly consistent sleep pattern, so have typically baulked at set times for mode / lighting changes, etc. I prefer various manual options for changing mode / lighting, whether they be physical smart switches (Samsung Buttons), dashboard tiles or voice activated changes.

That deals with irregularities at a home level. Individuals and their own sleeping habits relative to the rest of the house I have always intended to manage through individual room-based toggles for things like motion lighting. I already have it in place when I choose to manually control lighting in a room, turning off motion lighting rules because I have chosen to manually take control. I expect I will make use of the same controls (switches) in my rules if I want to implement something similar, such as when I have guests staying the night who would prefer to have motion lighting turned off.

In the situation that I have had in mind, and I think translates to what you described, I intended to have a virtual mode switch for the living space as well as separate switches for each bedroom, representing the “mode” for each space. If any bedroom “woke up” then the living space also woke up, but other bedrooms don’t necessarily to wake up. I intend to install smart switches in each bedroom, currently Samsung Buttons. If the main bedroom (my bedroom) does a long press on the Button, then the whole house wakes up (sorry, my house, my rules :slight_smile: ). If any other guest bedroom does the same, just their bedroom and the living space wakes up. If the button in the living space is long-pressed, all the bedrooms are woken up. Essentially I intend to remove most of the smarts.

I can provide more details here or point you to “other forums” where I have outlined my motion lighting overrides.



This is what i have done for our Bedroom.
Contact sensor on door and motion sensor in room, with 45 sec delay off.
If lights are off, contact open - Lights on.
Motion sensor takes over regardless then of contact sensor. I don’t use it to turn lights off.
As for sleeping. I have mine and my wifes phone trigger a makerAPI via tasker, when either of our phones get plugged in.
Once a phone is plugged in, it is “quiet” time and no motion or contact sensor works.
I also have a override motion v/switch. Basically if i turn the v/switch on, which ever state the lights were in, they stay that way until v/switch is off…
I do my logic in Node Red,


I base things on mode. I know you’ve seen my smart qi charger post using a contact sensor. Others use tasker type automations with the same efficiency. If one of us takes a nap, no matter what time of day, simply dock your phone and the bedroom will stay dark and the obnoxious lights around the house will act accordingly. Quiet time is quiet time. No matter what time a day. I’ve adjusted how the house interacts according to that mode. It’s worked really well for me. Another place I use a contact sensor is in the bathroom that turns the light immediately on when the door is closed no matter which mode and in night mode will turn the light immediately off when the door is opened. Modes play a huge role in how things interact in the Brandt residence. But, I’ve based everything on just a few modes. Home, Away, Quiet and Night. Works great for us. I do everything through node red these days.


Same. We simply turn one of our phones face down whilst charging and it makes (via tasker) our master bedroom go into a sleep mode. Also the ensuite bath.


I have several motion sensors all down low so that they don’t trigger while in bed, but do immediately we come in the door or get out of bed when it’s evening or night. I use 2 Withings sleep pads also to control the AC and alarm system arm/disarm (when both in bed, arm the alarm, when either out of bed, disarm) and to turn the lights off when we are both in bed. I have a contact sensor on the door but don’t use it for lighting at all. Just as an alarm sensor (eg. in the morning, sometimes the sleep pads don’t respond or respond fast enough and so the alarm would go off when we went out of the bedroom and it hadn’t disarmed. So I have a rule that if the door opens, and motion is sensed in the bedroom but not outside the bedroom, then disarm the alarm because it’s obviously us opening the door).

1 Like

I appreciate everyone’s responses and I think I have come to the conclusion that a contact sensor is not enough; I think I need another sensor that actually detects the occupancy of the bed outside of a manual Alexa call which can easily be forgotten, whether that be a phone charging which is cool but seems like a headache to setup/troubleshoot/maintain, or a pressure sensor of some kind.

I have been looking into a DIY pressure sensor with a NodeMCU and a force sensitive resistor; has anyone done one of these or know if I could use tasmota to handle the “smart” part of the sensor?

@Mike I have a similar setup with the house going to sleep when my phone is charging via tasker.
I like the idea of a second condition.
Finally figured out how to add a second condition.

Yep, happy to help. In tasker, under profiles, long click the particular profile you want to add a second “trigger”. It will popup with a few options, select add, and go from there. It’s green when it’s true. I additionally have a variable so that it’s not spamming my endpoints all night (not that it does, just in case it does).

1 Like

I like the idea of Tasker but as the only android user in my family it’s use is limited and secondly I have always been worried about the reduced battery life of my phone since it is always on in the background.

Can anyone speak to the hit Tasker has on their battery life if at all?

I don’t notice a difference in battery life!
I haven’t tested it to say for sure, but then again, I use my phone quite a bit during the day so I need to charge it nightly anyway

1 Like

I … love
my contact sensor pedestal. I call it that because the qi chargers struggled from heat, so they have become a place to put your phone that will turn off the house. 25 bucks and you’re done. One simple rule to change the mode in node red. Set it and forget it. I’ve loved it. I’m happy to share all of my rules I have set up for this.

1 Like

I haven’t noticed any major battery drain from tasker but I also have not tested it.
Tasker has been super reliable.
I run several tasker rules like text, phone calls, and low battery which trigger voice notifications. Since the kids are always running off to play with my phone.
As well as my good night rule.

I have the same problem though the wife only uses an iphone and have not found a work around for that other than auto running my good night rule when motion has stop after a set time at night.

1 Like