I keep forgetting to end my sleep in the app

I use the Sleep as Android MQTT to automate other things via Home Assistant - setting the app to sleep will turn off my lights for example, and my wake up alarms depend on my real time sleep state. I use an old phone to track my sleep and it all works pretty well.

Except there are times when I wake up and forget to turn off the sleep session, and so it runs for the rest of the day, which is both annoying for my data and battery. What strategies do I have to resolve this?

Auto sleep tracking didn’t seem to work too well, although I’m not sure why “no movement for 20 mins” isn’t an easy thing to implement.

Ideally I want a way to remotely control Sleep, so that something else can turn it off (and while we’re at it, on!). Is there an API that can be used for this?

Hi @sshaikh, even if you keep the phone on a floor, there is no “no movement” - the accelerometers are surprisingly sensitive, so they always pick up the micro-movements.

Anyways, you can use the intent API, stopping tracking is:
com.urbandroid.sleep.alarmclock.STOP_SLEEP_TRACK

You can find more details at https://sleep.urbandroid.org/docs/devs/intent_api.html.

1 Like

I suspected as much - and I’m guessing that’s why auto sleep detection is so hard.

Thank you for the intent API. Are there any which are externally available ie over http? If not any tips on how to expose this intent to home assistant? I suspect I’d need Tasker or the like in the middle?

Edit:

Seems the HA folk are ahead of me and can use the HA app as a bridge:

You need an app/service, that will send the intents to Sleep. Home Assistant should support directly webhooks.

Excellent - it’s all working as documented. Thanks for the tip!