Dont Turn Lights On when in Bed

Hi there,
I have this trivial issue and wonder how other people solved it in their automation systems.

There is a motion sensor in the bedroom that switches lights on and off. When i move in the bed it sometimes detects motion and switches lights on at night.

I don’t want to set up automation based on time as i got to bed and wake up during different times. And it is almost impossible to direct sensor the way that it covers most of bedroom but doesn’t cover the bed.

Ideally if im in the bed it shouldn’t switch the lights on but when im not it should.

I was reading about smart sheets that can detect if someone in the bed and sleeping. I guess this can be a solution but i didn’t find it in the UK. Also wristbands like fitbit know if you are sleeping but i read integration with HA is far from perfect.

I wonder how you guys solve this? Appreciate any help.

Thanks,
Alex

i dont use motion sensors for the bedroom

I’ve considered using a nodemcu and a force sensor or force sensing resistor (Something like this ) to create an mqtt sensor that detects when I’m in bed.

You could also use a bayesian sensor to use several factors to estimate whether you’re in bed, such as the time of day, frequency of motion sensor detections, time you’ve been home, etc.

Edit: you could also use multiple motion sensors positioned under your bed so that they only detect your feet on the floor.

I trigger a shortcut on my phone when it is connected to the charger by my bed, which sets an input_boolean in HA.

2 Likes

It is not exactly what you want but can you use an automation condition to disable the light coming on if everything is off downstairs or a door shut that you always shut at night…

I like the motion sensor under the bed idea but it would only be suitable if you don’t share a room.

depending on how technical you want to get, might be worth having a look at this,

1 Like

Similar to Crhass’s idea… Use a Basesian Binary Sensor to detect the probability you’re in bed. It can take several inputs (after 10pm, tv off, lights off, door locked, no motion elsewhere in the house, etc), and calculates a probability that you’re actually in bed. It’s a binary sensor so it would return true or false and would be easy to implement as a condition in your motion sensor/light automation. The example in the documentation I linked above shows how to implement the sensor in this exact situation so it should be pretty helpful.

A less technical way to solve this is to wear a sleep mask so when the lights turn on in the middle of the night you won’t wake up :stuck_out_tongue:

2 Likes

I use https://github.com/schollz/find3 to determine if both smartphones are in the bedroom for more than X minutes. If not then the light gets turned on.
I implemented it with this Appdaemon App.

2 Likes

I have a similar solution to @gpbenton. When I goto bed, I tell my Google Home and it turns off all the lights and TV, sets the temperature accordingly, and (most importantly) sets the ‘in_bed’ input_boolean in homeassistant to on.

When my alarm goes off, it switches it back off.

2 Likes

https://www.google.com/search?rlz=1C1GCEU_enUS821US821&ei=Xl3kW6zKBJGZ8AOqtbfwBA&q=home+assistant+bed+motion+sensor&oq=home+assistant+bed+motion+sensor&gs_l=psy-ab.3..33i22i29i30l9.12142.14833..14929...0.0..0.87.836.11....3..0....1..gws-wiz…0i71j33i22i10i29i30.6Q3xwhVq4cA

Found me this: Bed Occupancy Sensor

I placed the motion sensor under my bed. This way the light only turns on when feet are detected. So in bed = no motion detection.

3 Likes

How does this work? Android or iPhone?

Its an android.

I always charge my phone overnight on a Phillips AS111.

I use llama on the phone to detect that the phone is charging and connected to the bluetooth of the Phillips. When this occurs, I have a rule in llama to call a shortcut (set by http shortcuts) to call the api of HA to set an input_boolean.

Sounds rather complex explaining it all, but it has been working for a while and is very reliable, without having to do anything extra.

I’ve been holding off on all ‘sleep’ automations because I couldn’t find a way to detect when my wife was sleeping. I can’t really train her to press a button before bed because that seems unreasonable (I don’t want to do that either but I would put up with it, she wouldn’t). This solution seems rock solid. I’ll have to see if I can come up with something similar for the iPhone.

1 Like

You have the iPhone app available. That gives you a sensor that knows if the phone is charging or not. The other way would be to measure the power consumption on the outlet with the charger connecting to a smart plug. That way you know for sure your charging the phone by the bed.
When you unplug your phone you can trigger your morning routine if wanted.
Cheap and easy!
I would go for the weight sensors though. Because it’s more fun :smiley:

I still would need a way to detect that it’s plugged in the bedroom and not other places.

EDIT: I’ve also noticed that the app does not update the plugged/unplugged state quickly. Took roughly 7 minutes for the app to update the charging status and I forced a location change. Not sure if that triggered it.

Read my post again. There are actually two suggestions in there.

I use HX711 to read two 50kg load cells placed under my bed. Very easy to use. See below links.
https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide


Then I have automations to check if me and the wife are home and on the bed. Going to sleep, waking up, going to bathroom during the night… turning the specific lights to on when first one wakes up and another set when both are awake.

1 Like

ah, yeah, i only read your first line :joy::rofl:

I’ve overcome this by building a “night light” script.

It cancels any scripts i had running for automating the lights and turns that automation off, dims my main light down, sets my nanoleaf to a night time sequence and then turns both off after 20 minutes.

I have an added extra automation for the night light script to kick in after room presence has me in the bedroom for 20 minutes after 10pm.

The bedroom light automation is then turned back on in to my wake up sequence which is triggered by an alarm on my amazon echo/phone.