mirror of
https://github.com/sudoxnym/sleepd.git
synced 2026-04-14 03:26:53 +00:00
Compare commits
3 commits
b61f04e3e8
...
6f2786e8a7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f2786e8a7 | ||
|
|
9f1b774a18 | ||
|
|
bf8830a330 |
1 changed files with 93 additions and 57 deletions
150
README.md
150
README.md
|
|
@ -1,7 +1,3 @@
|
|||
<div align="center">
|
||||
|
||||
<img src="brands/icon.png" width="128" height="128" alt="sleepd icon">
|
||||
|
||||
# sleepd
|
||||
|
||||
**real-time sleep state tracking for home assistant**
|
||||
|
|
@ -9,12 +5,10 @@
|
|||
[](https://hacs.xyz/docs/faq/custom_repositories)
|
||||
[](LICENSE)
|
||||
|
||||
*processes sleep mqtt messages from android apps and exposes states, events, and controls to home assistant - automate your smart home based on whether you're awake or asleep.*
|
||||
*processes sleep mqtt messages and exposes states, events, and controls to home assistant - automate your smart home based on whether you're awake or asleep.*
|
||||
|
||||
---
|
||||
|
||||
</div>
|
||||
|
||||
## ✨ features
|
||||
|
||||
- **wake status sensor** — `awake` or `asleep` based on configurable thresholds
|
||||
|
|
@ -26,8 +20,10 @@
|
|||
|
||||
## 📱 compatible apps
|
||||
|
||||
- [sleep as android](https://sleep.urbandroid.org/) (primary)
|
||||
- any app that publishes sleep events via mqtt
|
||||
| app | notes |
|
||||
|-----|-------|
|
||||
| [sleep as android](https://sleep.urbandroid.org/) | primary |
|
||||
| any mqtt sleep app | publishes sleep events via mqtt |
|
||||
|
||||
## 📊 sensors
|
||||
|
||||
|
|
@ -46,19 +42,24 @@
|
|||
|
||||
*requires home assistant companion app*
|
||||
|
||||
- alarm dismiss / snooze
|
||||
- lullaby stop
|
||||
- sleep tracking start / stop / pause / resume
|
||||
- sleep tracking start with smart alarm
|
||||
| button | description |
|
||||
|--------|-------------|
|
||||
| alarm dismiss | dismiss active alarm |
|
||||
| alarm snooze | snooze active alarm |
|
||||
| lullaby stop | stop lullaby playback |
|
||||
| sleep tracking start | begin tracking session |
|
||||
| sleep tracking stop | end tracking session |
|
||||
| sleep tracking pause | pause tracking session |
|
||||
| sleep tracking resume | resume paused session |
|
||||
| sleep tracking start with smart alarm | start with smart alarm enabled |
|
||||
|
||||
## 📥 installation
|
||||
|
||||
### option 1: hacs (recommended)
|
||||
|
||||
1. add this repo to HACS custom repositories:
|
||||
```
|
||||
https://github.com/sudoxnym/sleepd
|
||||
```
|
||||
1. add to hacs
|
||||
|
||||
[](https://my.home-assistant.io/redirect/hacs_repository/?owner=sudoxreboot&repository=sleepd&category=integration)
|
||||
|
||||
2. search for **sleepd** in HACS and install
|
||||
|
||||
|
|
@ -70,19 +71,8 @@
|
|||
|
||||
### option 2: manual
|
||||
|
||||
copy `custom_components/saas` to your HA `custom_components` directory
|
||||
|
||||
## ⚙️ configuration
|
||||
|
||||
| option | description |
|
||||
|--------|-------------|
|
||||
| name | identifier for this user/device |
|
||||
| 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) |
|
||||
1. copy `custom_components/saas` to your HA `custom_components` directory
|
||||
2. restart home assistant
|
||||
|
||||
## 📡 mqtt setup
|
||||
|
||||
|
|
@ -97,39 +87,85 @@ sleepd expects json messages with an `event` field:
|
|||
{"event": "rem"}
|
||||
```
|
||||
|
||||
### sleep as android config
|
||||
<details>
|
||||
<summary><strong>📲 set up Notify for Mi Band 7</strong></summary>
|
||||
<ol>
|
||||
<li>pair **Mi Band 7** as you normally would with <a href="https://play.google.com/store/apps/details?id=com.xiaomi.wearable&hl=en_US">Mi Fitness</a></li>
|
||||
<li>obtain auth key for Notify app using ADB</li>
|
||||
</ol>
|
||||
|
||||
1. open sleep as android → settings → services → automation → MQTT
|
||||
<pre>
|
||||
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}'
|
||||
</pre>
|
||||
|
||||
2. connection string:
|
||||
```
|
||||
tcp://user:pass@your-ha-ip:1883
|
||||
```
|
||||
<p>credit: <a href="https://www.reddit.com/r/miband/comments/15j0rfq/comment/kxlyzc6/">iamfosscad</a></p>
|
||||
|
||||
3. set topic to match your sleepd config
|
||||
<ol start="3">
|
||||
<li>uninstall **Mi Fitness**</li>
|
||||
<li>download/install <a href="https://play.google.com/store/apps/details?id=com.mc.miband1&hl=en_US">Notify for Mi Band</a></li>
|
||||
<li>follow prompts, input auth key, select Mi Fitness is not installed</li>
|
||||
<li>enable Sleep As Android in Notify settings</li>
|
||||
</ol>
|
||||
</details>
|
||||
|
||||
4. enable automatic tracking
|
||||
<details>
|
||||
<summary><strong>🔐 extracting the Zepp <code>authKey</code> on a rooted android device</strong></summary>
|
||||
<pre>
|
||||
su
|
||||
cd /data/data/com.huami.watch.hmwatchmanager/databases/
|
||||
ls origin_db_*
|
||||
sqlite3 origin_db_1234567890 "SELECT AUTHKEY FROM DEVICE;"
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li>⚠️ do not unpair before extracting</li>
|
||||
<li>use with caution – root required</li>
|
||||
<li>modified apps are available on <a href="https://geekdoing.com">GeekDoing</a> and <a href="https://freemyband.com">FreeMyBand</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
|
||||
<h3>🛌 <a href="https://play.google.com/store/apps/details?id=com.urbandroid.sleep&hl=en_US">sleep as android setup</a></h3>
|
||||
<ol>
|
||||
<li>open the app and follow setup</li>
|
||||
<li>settings wheel > services > automation > MQTT</li>
|
||||
</ol>
|
||||
|
||||
<pre>
|
||||
(tcp/ssl)://(MQTT User):(MQTT Pass)@(HA URL):(port)
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li>topic: must match config</li>
|
||||
<li>client id: any unique id</li>
|
||||
</ul>
|
||||
|
||||
<ol start="4">
|
||||
<li>enable automatic tracking</li>
|
||||
<li>sensor: sonar or accelerometer</li>
|
||||
<li>wearables > **Xiaomi Mi Band** > test sensor</li>
|
||||
</ol>
|
||||
|
||||
## ⚙️ configuration
|
||||
|
||||
| option | description |
|
||||
|--------|-------------|
|
||||
| name | identifier for this user/device |
|
||||
| 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) |
|
||||
|
||||
## ⌚ tested wearables
|
||||
|
||||
- xiaomi mi band 7 (via notify for mi band)
|
||||
- garmin fenix 7x (via garmin alternative)
|
||||
- amazfit gtr3 pro
|
||||
|
||||
<details>
|
||||
<summary>mi band 7 auth key extraction</summary>
|
||||
|
||||
```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}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 📜 license
|
||||
|
||||
MIT — do whatever you want with it
|
||||
| device | method |
|
||||
|--------|--------|
|
||||
| xiaomi mi band 7 | notify for mi band |
|
||||
| garmin fenix 7x | garmin alternative |
|
||||
| amazfit gtr3 pro | native |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -137,6 +173,6 @@ MIT — do whatever you want with it
|
|||
|
||||
made by [sudoxnym](https://sudoxreboot.com) ⚡
|
||||
|
||||
*formerly known as saas*
|
||||
*formerly known as [saas - sleep as android status](https://github.com/sudoxreboot/saas/tree/main) — the app is capable of working with any mqtt sleep app now*
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue