Setting sleep/awake state with smartphone charger and smart plug

These flows set the sleep state when a smartphone is connected to the charger via a power measuring smart plug. When you disconnect your phone, it sets your status to awake after one minute. I use Fibaro smart plugs, but it might work with other brands as well.

Setting asleep is easy, as the connected phone is drawing a decent amount of power when charging starts.

Set Dennis’ status to asleep
When The power changed
And Power is greater than 4
Then mark Dennis asleep

When the battery of the phone is full, the charger will keep charging it a few times per minute, because it is using a little power constantly.

I have created a countdown timer for 60 seconds, that starts running every time the power use of the charger changes AND is 0 W.
Every time the power use changes AND is higher than 0 W, the timer is stopped. This happens multiple times per minute from the moment the phone is fully charged.
When the phone is disconnected, the used power will stay at 0 W, so the timer will keep counting down to 0.
When the timer is at 0, my status is set to awake.

I did use The Countdown App, created a timer TimerDennis and created two flows:

Dennis Phone Power
When the power changed
And Power is exactly 0
Then Start countdown timer TimerDennis 60
Else Stop countdown timer TimerDennis

Dennis gets up
When Timer reaches zero (0) TimerDennis
Then mark Dennis awake

Values can be different for various phones, chargers and smart plugs, but the basics should work for everyone.



If i may make a liitle side note about the flow, if you phone is set to sleep… and for example someone calls you. You take the phone from the charger and the call is longer then 1 minute!!! It wil set you awake. Guess thats not something you want, maybe depends on the actions you have givin the awake flow.

That’s true. I use a very long charging cable, so I can use it with the charger connected. Of course you can tweak the flows as much as you need, these are just the basics.


I use a button from remotec that i push when i go to sleep.
Then, everything that needs to go off is turned off, google hub tells me a short review, like the temperature outside and in the bedroom, how many kwh i have collected with my solarpanels, then it tells me if i have to put the trash outside the next morning and at what time i have to work. And the radio turns on, coz i like to listen it while falling asleep (sonos)

When i wake up by the alarmclock i have created with homey (dynamically) will make a sound over the sonos, i push the same button but then it says goodmorning and again i get a little review… like if it is raining the comming hour, again if i have to put the trash outside, the temperature, etc.
The alarmclock repeats every 5 minutes as long as i stay in bed.
And from that point i woke up, in every room i get notified every 5 minutes what time it is and 30 minutes before i have to be on my work and I haven’t left yet, it tells me that i have to hurry :slight_smile:

Works like a charm :slight_smile:


Of course there are many ways to set up the morning routine. I really want to automate stuff, so I try to avoid having to do anything more than I was used to do, like pushing buttons. Not that there’s anything wrong with that, but I prefer not to.
I use it mostly to trigger the heating system at this moment, but I’m sure I will add other, silent, functions in the future. If anything starts making noise in the bedroom, the partner acceptancy factor will drop many points per day, I’m afraid. :wink:

I understand. But i doubt if it works… only thing i earlier came up with, is by watch which notice that i am awake. But then again, when u wake up coz u need to go to he bathroom, that the system fails again.
Maybe you can fix it by multiple solutions… like icalendar2voice and put your routine in google agenda. You is for your schedule for school or work and name it like that.
Then, you can make variables that know if you have to work or go to school. U do know how many time before that you have to wake up.

My first reply was for weekends or days off… but when i have to work, i dont have to do anything. Homey know that i have to work, so i will be awake at that time the alarmclock goes off.

But for the time you go to sleep is way to difficult. Coz you wont sleep right away but i bet you wanne fall asleep in darkness. So, some piont you have to do something.

Unless you never read, watch tv or anything before you go to sleep. Then you can automate with icalendar2voice that everything goes off at, lets say 23:00 oclock and you have to sleep then…

Even with presure sensors under the matras you will have the same issues.

Even tho when you have a day off, you can automate it with a motion sensor when you leave the bedroom. Use timestamps to exclude bathroom visits.

Or… if it was possible, connect your brain to homey… but also here you will have a problem with the time during falling asleep and bathroom visits.

I bet it is not possible… if you can do it anyway, tell me! :slight_smile:

I think it’s great peeps sharing their flows. And that’s what’s this category is all about aye? Reactions with “I use a button for it” has nothing to do with sharing a great flow which other peeps can use to their own needs.


I do the same thing and this works really good. The only difference in my situation is that I use a motion sensor downstairs to set the users to awake. With more people in one home it is difficult to determine who is awake.

I do the same thing for sleeping.
But to tell the house I’m awake, I have to close the window in the bedroom and trip a motionsensor in the livingroom :slight_smile:

Thank you for this flow. I have been struggeling getting things right.
getting shouted at by the wife telling me ''the lights and radio are on again ‘’ in the middle of the night was getting old. ( morning routine)
thanks alot for this! you just made my life a little better?

1 Like

I have a motion sensor under each side of the bed. When i trigger the sensor under my side of the bed and connect my phone to the charger homey no i am going to bed. When my girlfriend trigger the sensor on here side and conect here phone to the charger homey no it to.

Wake up works the other wau around. When i put my feet next to my side of the bed and put my phone from te charger homey no that i wake up. It also work when i disconnect the charger en after that i put my feet next te the bed. For my girlfriend it work the smae way on here side.

1 Like

what i use is:

WHEN device is plugged in THEN start “5 sec sleep delay” flow in homey.

WHEN device is unplugged THEN start wake up flow in Homey

WHEN 5 sec sleep delay flow has started THEN start “sleep Name flow” after 5 seconds

WHEN sleep Name flow started ANDenergy smartplug is >3 THEN set Patje to sleep

WHEN wake up flow has started AND Patje is a sleep THEN set Patje awake.

Here we always charge the phones in the bedroom connected to a smartplug.
Because ifttt is very fast to notice that my phone is plugged in, i had to make a delay to see the energy change of the smartplug.

@Martijn02091989 That’s nice to hear, glad this could help you!

This sounds really cool!

  1. How did you manage to tell google hub (I have a google mini) a short review if you push a button (I have the aqara switch)?

  2. How did you manage to let the alarm of homey sound over the sonos? Is it also possible to make the homey alarm sound over the google home mini?

Thanks very much!

And sound over the sonos with the sonos app And soundboard

Don’t mention the typo in: kilowat… that is for TTS to speakout it correctly.
Here is also the shame that when u collect 2.10 kwh it will say: ten over 2 (as the time).

Gemiddelde tijd buiten, is the average temp of all outside sensors.

1 Like

Beste moenieseuren,

Ik probeer uw flow over te nemen en gebruik hiervoor een Alecto smartplug. Deze heb ik middels de Tuya app kunnen toevoegen aan Homey. Als ik de flow wil maken, dan heb ik bij “when” alleen de optie “als apparaat aan/ uit gezet wordt” en niet de mogelijkheid om het verschil in stroomverbruik te gebruiken.

De plugs kunnen ook energie meten en dit kan ik ook terug zien in de Tuya app, het is mij dus onduidelijk waarom ik deze optie niet kan kiezen.

Zie ik iets over het hoofd?

Het ziet ernaar uit dat de stroommeting uit de Tuya app niet bruikbaar is als voorwaarde in Homey flows. Je zou de vraag eens bij de maker van de Tuya app kunnen neerleggen.

hello, i think this is my first post, i read pretty a lot but often too shy to dare.
you guys are having well organised lives and can settle a routine with charging phone or door closed etc. i sometimes fall asleep in the afternoon with my phone on in my hands and none of your tricks is convenient to my bohemian life.
As i am sharing my flat, it is pretty important for each mate to know if the other one is sleeping or not. sleep monitoring iot things are globally overpriced and i suddenly had the idea to combine a seat sensor used in automotion to trigger the unfasten seatbelts or fire the airbags. I bought one for less than 5 euros on a famous chinese page and checked that it is in reality a tension free item, perfectly compatible with a fibaro binary sensor. By the way, note that the FGBS have 2 dry contact entrance so you also can put one on the other side of the bed and still can monitor the temperature too!
if i am in bed: i mark myself as sleeping. if i just go to the toilets for less than 10 minutes, it still mark me as sleeping. if it is during the day light and have slept more than 8 hours, blinds gently raise at 50% to help me having a day life.
hope this will help somehow.