Wake Sensor/Trigger on WearOS


Is there any way we could get a wake sensor/trigger from wearOS? I’d love to be able to automate things when I wake up or go to sleep such as turning on/off lights, putting my watch automatically in DND, changing thermostats, etc. The watches themselves should have this information, though im not sure if it’s accessible.

It’d be neat to hook into data such as sleep state, heart rate, etc


Edit: looks like sleep_confidence is accessible. A combination of that and counting the number of steps looking at the Activity sensor data would probably be pretty accurate if that could be exposed.

Although it may indeed be possible, the recommended way to do it, is to use something like SleepAsAndroid on the paired phone which can publish sleep state information over MQTT.

Why wouldn’t we just really on sleep confidence? Because it is rubbish. My phone will have a sleep confidence of >90% just because it’s been sitting still, but if I pick it up and interact with it, the sleep confidence score doesn’t immediately drop - it very very slowly drops. Even playing a full screen game isn’t enough of a hint to Google that I’m not asleep!

The watches sleep confidence score will likely be just as bad, because it comes from Google Play Services so it’s bound to be as inaccurate as the phone is.

As you can see, it’s all over the place. When was I actually asleep? About 6:30am to 2pm

1 Like

Wouldn’t something on WearOS be a lot more accurate and take into consideration heart rate and whatnot? Do health tracking apps use sleep_confidence, or heart rate algorithms themselves?

Yes, it should be more accurate, but also more of a battery hit on the small watch battery. The sleep confidence alone, appears to be based on solely on the accelerometer and ambient light and some AI magic… Sleep API  |  Google Developers

My GW4 is pretty amazing at sleep tracking, knowing when I’m asleep / awake with very good accuracy.
Unfortunately I don’t see any way to use that information in home assistant, the new firmware can use that to trigger smart things automations but not HA it seems

1 Like

I’ve been trying to figure this out for awhile now, it’s such a great idea … allowing for more Human centric automations. I want my home to no what I need without me telling it. Tempurture changing on my way home from work based off my body temp, lighting based off potential stress levels etc

1 Like

I’m also interested in this with WearOS.

As to how a phone handles sleep, I completely agree, it’s 90% bogus. How can you phone know you are asleep if you aren’t a millennial? Some of us put our phones down for hours at a time.

A watch has sensors and firmware dedicated to sensing sleep state, not just motion/accel data.

So far all I have found are third party loggers which will take the sensor data and publish it to multiple fitness tracking cloud apps. On the other end of the spectrum there is the the WearOS APIs, transferring data to the phone and then publishing it via another android app on MQTT, maybe…

Some of the data off the sensors in raw format is actually “raw” sensor data. So it’s possible, for example, you won’t get a heart rate what you’ll get is a stream of values detected by the light detector, which needs minimal signal processing to convert to a heart rate. The values from the SPO2 sensor might be even harder to process. To summarise I believe a lot of the raw signal processing for the sensors is included in proprietary code in the fitness trackers. As to whether there is an open source library for signal processing that needs done on the watch, I don’t know.

The idea would be for the periodic scans to run through the biometrics scans, using a library (if we can find it) to convert raw sensor data into heart rate, motion, sleep state, stress level etc. Then use an Android data transfer API to send that data as JSON to the phone. Pick it up there (by subsribing to that data channel), and publish it by MQTT.

The periodicity and efficiency of this will determine the battery impact.

For instance a desirable event might be “hasStartedSleeping” or “hasAwoken”. Then a half hourly update would probably be sufficient for many automation tasks. If you want more instant response, like to turn the lights off, I think you will struggle.

Once you have spent the battery on the watch doing the initial signal processing, what you do on the phone will also matter. Android (and Apple) have fairly aggressive power saving systems and expecting the Wifi to be on, or even to wake up for you app is… optimistic. Apps may have to schedule their transfers and simple sleep waiting on the Wifi being available.

In short, having to do it from the ground up would be pretty difficult. What we need to do is find off-the-shelf components for as much of the chain of communication as possible. Definitively starting with getting pre-processed values for biometrics as opposed to raw sensor data. Another component would be a generic data transfer or event API, maybe Tasker / WearTasker could be used or modified for that… similarly Tasker could be employed on the phone for responding to state changes and events based on the data received from the watch.

One interesting class of application will be my next research focus. They are sensor aggregators. Some fitness types have more then “one” sensor, like a watch. Some have heart chest strap sensors and blood pressure sensors etc. Apps which intend to aggregate this data into a single display… will have code and functionality we could use.

1 Like

Submitted a PR to add a sensor for the user activity state as reported by the new Health Services API available for Wear OS 3 devices. This will report when you fell asleep and woke up. Did some real world testing last night and its fairly close to what fitbit recorded from my pixel watch.


this new API will also let us get more data as well however I do not see Stress level mentioned as a DataType


For older devices most likely the sleep API will work better on a wearable device as light and motion will indeed have different values compared to a sitting phone :slight_smile:

1 Like

This is perfect for my use case, if it works… My wife was just complaining (again) that I won’t turn my bed light off after I fall asleep reading. So, I really hope it works for me. Will test tonight!

1 Like

Worked totally fine. Light went off when I was asleep.



So, how do i get this to work? I am e bit newbie on this

You need to enable the activity state sensor in the wear os app. Open the app on the watch, scroll down to settings > manage sensors > health services and from there enable the sensor and grant permissions. If you do not see health services then your device does not support it.

i found the sensor, but it has only reported passive since then… So i am not getting any info from the sensor at all. Any clue what to do?

do the other sensors report? What device is this? If its Samsung have you checked the galaxy wearable app to make sure the HA app has background access?

It is a galaxy watch 4…the backround was disabled. Enabled it and now just wait and see

I tried and tur ed backround data on. But stil my sensor doesnt report anything back. What to do now?

We would need to see the device logs from logcat unfortunately no easy way to get them other than using adb or Android studio. You’ll want to force stop the app and open then pull the logs.

I’m having a similar problem – all other Health Services metrics are showing up in HA, but ‘activity state’ is constantly “unknown”.

I’ve checked HA’s permissions on both the phone & the watch and they have full access even in the background. Not sure what I’m missing :frowning:

I have yet to experience this issue, if you guys see this issue then we need to see the logs as mentioned earlier