Sleep as Android¶
Usage of non-free (as-in freedom) software ahead
Sleep as Android is a proprietary application that has a integration in Gadgetbridge, which some may find it convenient to have.
Gadgetbridge can provide data from paired gadgets to proprietary Sleep as Android app, allowing Sleep as Android to collect & track sleep statistics with your gadgets paired in Gadgetbridge. Support for Sleep as Android has been added in pull request #3687.
Supported devices¶
- Bangle.js (with pull request #3785), requires installing the provider see below
- Garmin (older devices might not be supported)
- Huami devices, including those before Zepp OS (Mi Bands 4/5/6, some Amazfit devices, with pull request #6089)
- Pebble devices support a standalone separate integration - see the PebbleKit
- Xiaomi protobuf (with pull request #6089)
- Zepp OS devices
Mi Band 1, 1A and 1S are not supported.
What each device family can provide to Sleep as Android:
| Family | Accelerometer | Heart rate | R-R Intervals | SpO2 | Notifications | Alarms |
|---|---|---|---|---|---|---|
| Bangle.js | Watch alarm slot | |||||
| Garmin | If the watch supports HRV | If the watch supports SpO2 | Vibration (find device) | |||
| Huami and Zepp OS | Periodic fetch, if the watch supports SpO2 | Watch alarm slot and vibration | ||||
| Xiaomi protobuf | Vibration (find device) |
Setting up¶
After installing Sleep as Android, enable the Wearables add-on, with selecting the "DIY" option since Sleep as Android has not yet whitelisted Gadgetbridge.
Then, use the package name matching the version of Gadgetbridge you have installed:
| Version | Package |
|---|---|
| Mainline | nodomain.freeyourgadget.gadgetbridge
|
| Bangle.js | com.espruino.gadgetbridge.banglejs
|
| Nightly | nodomain.freeyourgadget.gadgetbridge.nightly
|
| Nightly Bangle.js | com.espruino.gadgetbridge.banglejs.nightly
|
| Nightly No Pebble | nodomain.freeyourgadget.gadgetbridge.nightly_nopebble
|
Then in Gadgetbridge, you must enable the Sleep as Android integration in the preferences, as well as select the device that will be used to send data to Sleep as Android.
You can do that by going " Settings → External Integrations → Sleep As Android".
How it works¶
- Gadgetbridge only powers the sensors that Sleep as Android asks for when tracking starts. If you turn off heart rate or oximetry in Sleep as Android, the watch doesn't measure them ( pull request #6922).
- If the provider device is disconnected when Sleep as Android starts tracking or rings an alarm, Gadgetbridge connects it and sends the request once it is ready, for up to 90 seconds ( pull request #6923).
Not yet released
Support for this feature has been added to Gadgetbridge's codebase, but is not yet released. It is already available in the nightly releases.
- If the next alarm is skipped or dismissed in Sleep as Android ahead of time while no sleep tracking is running, Gadgetbridge disables the alarm it set on the watch ( pull request #7001).
Bangle.js¶
Along with above steps, additionally, Acceleration Data Provider app must be installed on Bangle.js to send acceleration data over Bluetooth, thus can be used for Sleep as Android.
Alarms set by Sleep as Android are written to the watch, in the slot chosen in Alarms slot.
Garmin¶
When an alarm rings in Sleep as Android, the watch vibrates using "find device" until the alarm is stopped.
R-R intervals are only provided by watches that support HRV measurement, and SpO2 only by watches that support SpO2.
Huami and Zepp OS¶
Alarms set by Sleep as Android are written to the watch, in the slot chosen in Alarms slot. When an alarm rings in Sleep as Android, the watch also vibrates a few times. Vibration hints from Sleep as Android are supported.
While tracking, Gadgetbridge fetches the recorded SpO2 samples from the watch every Fetch interval (seconds). For new samples to be recorded, all-day SpO2 monitoring needs to be enabled in the device settings.
Xiaomi protobuf devices¶
To get movement data from the band, Gadgetbridge starts a hidden workout on the band while Sleep as Android is tracking. The band shows a workout screen with the elapsed time and heart rate when tracking starts, this is expected, don't stop the workout on the band.
When an alarm rings in Sleep as Android, the band vibrates in bursts until the alarm is stopped in Sleep as Android, or until Maximum alarm vibration (minutes) (5 by default) is reached ( pull request #6927). Using "find device" in Gadgetbridge also stops the vibration. Vibration hints from Sleep as Android are supported.
Further steps¶
Sleep as Android app exposes an intent API which can be used together with device events, so you can let Sleep as Android know when Gadgetbridge detects an event from your gadget.
For "Send Broadcast" action in Gadgetbridge, you can use these settings to start and stop tracking on Sleep as Android:
| Purpose | Set "Broadcast message" to | Set "Broadcast package" to |
|---|---|---|
| Start sleep tracking | com.urbandroid.sleep.alarmclock.START_SLEEP_TRACK
| com.urbandroid.sleep
|
| Stop sleep tracking | com.urbandroid.sleep.alarmclock.STOP_SLEEP_TRACK
| com.urbandroid.sleep
|
Refer to Sleep as Android's documentation for all actions.