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.