mirror of
https://github.com/sudoxnym/sleepd.git
synced 2026-04-14 11:37:11 +00:00
docs: generic mqtt processor, not sleep as android specific
This commit is contained in:
parent
74d5b32c21
commit
f1fd191e85
3 changed files with 36 additions and 46 deletions
68
README.md
68
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# sleepd
|
||||
|
||||
> sleep as android status integration for home assistant
|
||||
> real-time sleep state tracking for home assistant via mqtt
|
||||
|
||||
[](https://hacs.xyz/docs/faq/custom_repositories)
|
||||
[](LICENSE)
|
||||
|
|
@ -9,14 +9,18 @@
|
|||
|
||||
## what it does
|
||||
|
||||
sleepd listens for Sleep As Android MQTT messages and exposes sleep state, events, and controls to Home Assistant. track when you're asleep, detect snoring, control alarms, and automate your smart home based on your sleep.
|
||||
sleepd processes sleep-related mqtt messages from android apps that track sleep in real time. it exposes sleep states, events, and controls to home assistant - letting you automate your smart home based on whether you're awake or asleep.
|
||||
|
||||
**compatible apps:**
|
||||
- [sleep as android](https://sleep.urbandroid.org/) (primary)
|
||||
- any app that publishes sleep events via mqtt in a compatible format
|
||||
|
||||
## sensors
|
||||
|
||||
| sensor | description |
|
||||
|--------|-------------|
|
||||
| wake status | `awake` or `asleep` based on configurable states and durations |
|
||||
| sleep stage | current stage from sleep as android (light, deep, rem, awake) |
|
||||
| sleep stage | current stage (light, deep, rem, awake) |
|
||||
| sleep tracking | whether tracking is active or paused |
|
||||
| alarm event | alarm events like snooze, dismiss, skip |
|
||||
| sound | snore, talk, cough, and other detected sounds |
|
||||
|
|
@ -46,32 +50,41 @@ sleepd listens for Sleep As Android MQTT messages and exposes sleep state, event
|
|||
|
||||
4. add integration via UI or click below:
|
||||
|
||||
[](https://my.home-assistant.io/redirect/config_flow_start/?domain=sleepd)
|
||||
[](https://my.home-assistant.io/redirect/config_flow_start/?domain=saas)
|
||||
|
||||
## configuration
|
||||
|
||||
| option | description |
|
||||
|--------|-------------|
|
||||
| name | identifier for this user/device |
|
||||
| topic | mqtt topic (must match sleep as android settings) |
|
||||
| topic | mqtt topic to subscribe to |
|
||||
| awake duration | seconds of awake events before marking as awake |
|
||||
| sleep duration | seconds of sleep events before marking as asleep |
|
||||
| awake states | which states indicate being awake |
|
||||
| sleep states | which states indicate being asleep |
|
||||
| mobile app | companion app target for buttons (optional) |
|
||||
|
||||
## mqtt message format
|
||||
|
||||
sleepd expects json messages with an `event` field:
|
||||
|
||||
```json
|
||||
{"event": "sleep_tracking_started"}
|
||||
{"event": "sleep_tracking_stopped"}
|
||||
{"event": "alarm_alert_start", "value1": "1733580000000"}
|
||||
{"event": "light_sleep"}
|
||||
{"event": "deep_sleep"}
|
||||
{"event": "rem"}
|
||||
```
|
||||
|
||||
## sleep as android setup
|
||||
|
||||
1. open sleep as android > settings > services > automation > MQTT
|
||||
|
||||
2. connection string format:
|
||||
2. connection string:
|
||||
```
|
||||
tcp://user:pass@your-ha-ip:1883
|
||||
```
|
||||
or with ssl:
|
||||
```
|
||||
ssl://user:pass@your-ha-ip:8883
|
||||
```
|
||||
|
||||
3. set topic to match your sleepd config
|
||||
|
||||
|
|
@ -79,49 +92,26 @@ sleepd listens for Sleep As Android MQTT messages and exposes sleep state, event
|
|||
|
||||
## compatible wearables
|
||||
|
||||
tested with:
|
||||
tested with sleep as android:
|
||||
- xiaomi mi band 7 (via notify for mi band)
|
||||
- garmin fenix 7x (via garmin alternative - paid)
|
||||
- amazfit gtr3 pro (may require root for auth key)
|
||||
- garmin fenix 7x (via garmin alternative)
|
||||
- amazfit gtr3 pro
|
||||
|
||||
<details>
|
||||
<summary>mi band 7 setup with notify</summary>
|
||||
<summary>mi band 7 auth key extraction</summary>
|
||||
|
||||
1. pair band with mi fitness app
|
||||
2. extract auth key via adb:
|
||||
```bash
|
||||
adb shell
|
||||
grep -E "authKey=[a-z0-9]*," /sdcard/Android/data/com.xiaomi.wearable/files/log/XiaomiFit.device.log | \
|
||||
awk -F ", " '{print $17}' | grep authKey | tail -1 | awk -F "=" '{print $2}'
|
||||
```
|
||||
3. uninstall mi fitness
|
||||
4. install [notify for mi band](https://play.google.com/store/apps/details?id=com.mc.miband1)
|
||||
5. enter auth key during setup
|
||||
6. enable sleep as android in notify settings
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>zepp auth key extraction (rooted)</summary>
|
||||
|
||||
```bash
|
||||
su
|
||||
cd /data/data/com.huami.watch.hmwatchmanager/databases/
|
||||
sqlite3 origin_db_* "SELECT AUTHKEY FROM DEVICE;"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## changelog
|
||||
|
||||
**1.0.0** - rebranded from saas to sleepd, removed next alarm sensor
|
||||
|
||||
**0.2.1** - fixed manifest error, config reconfigure now works
|
||||
|
||||
**0.2.0** - fixed deprecation warnings for HA 2025.12 (breaking: re-add integration after update)
|
||||
|
||||
**0.1.0** - fixed wake status timing, sound sensor bugs
|
||||
**1.0.0** - rebranded, removed next alarm sensor, generic mqtt focus
|
||||
|
||||
---
|
||||
|
||||
*formerly known as [saas](https://github.com/sudoxnym/saas)*
|
||||
*formerly known as saas*
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"domain": "saas",
|
||||
"name": "sleepd - Sleep As Android Status",
|
||||
"name": "sleepd - Sleep MQTT Processor",
|
||||
"codeowners": ["@sudoxnym"],
|
||||
"config_flow": true,
|
||||
"dependencies": ["mqtt", "mobile_app"],
|
||||
"documentation": "https://www.github.com/sudoxnym/sleepd",
|
||||
"issue_tracker": "https://www.github.com/sudoxnym/sleepd/issues",
|
||||
"documentation": "https://github.com/sudoxnym/sleepd",
|
||||
"issue_tracker": "https://github.com/sudoxnym/sleepd/issues",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "sleepd - Sleep As Android Status",
|
||||
"name": "sleepd - Sleep MQTT Processor",
|
||||
"render_readme": true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue