Homey Community Forum

Good way to detect if we are sleeping

Hey all,

I’m struggling with the following : I have a “sleep” mode virtual switch, if that is turned on, behavior of lights, temperature and alarms is changed. I’ve now configured that it listens to a Hue Tap sensor, if you tap it it switches between on/off on the virtual switch. Works fine, but sometimes someone forgets to tap te button and it stays in sleeping mode, or the other way around and then lights/temps etc are not working as expected.

What do you guys use to determine if everyone is sleeping or not?


Put a plug with energy meter before your phone charger.

If - energy is greater than 0
And - nobody is sleeping
Then - Mark as sleeping

If - energy is exactly 0
And - someone is sleeping
Then - Start countdown timer of 8 hours

If - Motion is detected in stairway
And - Countdown timer is running
Then - Mark as Awake and stop countdown timer.

The trick with motion sensor and countdown timer is needed because your phone charges faster then you get your rest.


Ok, and what if countdown is running and for some reasson you walk the stairway and its still in the middle of night?

not really a night-peeing person myself but I think that is easily overcome by:

  • add an extra condition. e.g. it’s after 4:30 AM
  • change the motion sensor in the stairway by e.g. a contact sensor in your sock drawer or something else that is part of your daily morning routine.

Just was curious :+1:

And another thing, probably you already have that tackled. But what about the Phone charger thats plug in whole day? or do you manuely plug it in for the night.

Just because of safety reassons (we al know the risk of leaving the charger in) Do you let it be switch off when homey sets you awake!!!

1 Like

Actually the charger is now ON all day long (build in Qi-charger in nightstand). But your comment makes me think about expanding the flow a little further. Thanks for that.


Yw, i let switch on, at 21.30 uur and when at home. And let it switch of again when the alarm clock goes or if i dont have set a alarm, when my daily routine start with making coffee

1 Like

I’m thinking of using my indoor Netatmo base unit for the same purpose.

It measure co2 and noise.

When time

And co2 < 600

noise < 40 db

Then sleep.


I am using an Aqara vibration sensor and an Aqara motion sensor. Those are really cheap.

I’ve got the vibration sensor under the mattres. It is not perfect as it is not possible to change the sensitivty of the alarm with the zigbee protocol in Homey. But I am using change of vibration strength as trigger. (must be above 3, to avoid false triggers).

The montion sensor is placed under the bed. When it is triggered it marks me as awake. It also turns on lights under the bed that lightens the floor just enough to walk around. It also disables the flow for the vibration sensor for like 8 minutes for cases like “I get in the bedroom sit down on the bed to put on socks.”

1 Like

Just curious, and thinking… whats happend when got out of bed in the night for going to the toilet or whatever reasson?

The motion sensor under the bed detects me getting out of bed. Turning on ligths that is needed. When I get back in bed the vibration sensor detecs that I am back in the bed.

But I am using change of vibration strength as trigger. (must be above 3, to avoid false triggers).

Good Day. How it is possible?

I am using withings sleep through ifttt for this.
This is working really well. A bit expensive though :cry:

1 Like

We have to nightstand lamps by our bed that turns on when someone enters the bedroom. On the bedstand there is a double-button that turns the lights off when you are about to sleep. This also activates sleep-mode.

I use two flic buttons on our bedside tables that put us to asleep and awake. I also use ‘reset flows’ that configure my apartment to default settings. I use this to mark everyone as awake, reset my light scenes to ‘normal’ etc. This flow just fires at 14:00.

Power consumption on plug

Related: https://hackaday.com/2019/09/11/does-your-home-assistant-know-when-you-are-sleeping/

1 Like

I recently found this:

and this:

What I do is use an power plug and whenever I plug in my phone I measure the power change which puts me to sleep. Since loading is prfetty unpredicatble as a proces the absence of power taken is not good to mark me awake.

For marking myself awake i use IFTTT to see when the power plug is unplugged from the phone. In android with IFTTT I can trigger a homey flow that marks me awake. Works pefect and without any delay.

to sleep:
If - power changed
And - power > 0
And - awake = YES
Then - change awake into NO
And - Mark me as sleeping

waking up:
If IFTTT applet start flow with tag wakker
and awake is No
then - markt me awake
and - set awake to YES

Long time ago but I now have the same problem. How to detect sleep. The charger option is not the best, I often forget or don’t care about my phone. I ordered some vibration sensor seems most reasonable for me. Will see how this turns out for me.
Set awake is easy, if after 6 in the morning and activities in two rooms detected.