mirror of
https://github.com/sudoxnym/sleepd.git
synced 2026-04-14 11:37:11 +00:00
v1.0.0 - rebrand complete, clean readme
This commit is contained in:
parent
7b62009e0d
commit
a95a4f7c30
2 changed files with 101 additions and 184 deletions
283
README.md
283
README.md
|
|
@ -1,210 +1,127 @@
|
|||
<p align="center">
|
||||
<a href="https://hacs.xyz/docs/faq/custom_repositories">
|
||||
<img src="https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge&logo=home%20assistant&labelColor=202020&color=41BDF5" alt="add to hacs">
|
||||
</a>
|
||||
</p>
|
||||
# sleepd
|
||||
|
||||
<h1>🌙 sleepd - Sleep As Android status</h1>
|
||||
> sleep as android status integration for home assistant
|
||||
|
||||
<h2>🚨 0.2.0 breaking changes 🚨</h2>
|
||||
due to changes in **Home Assistant** 2025.12, you **must** remove your existing **sleepd** integration entries and re-add them after updating to this version.
|
||||
[](https://hacs.xyz/docs/faq/custom_repositories)
|
||||
[](LICENSE)
|
||||
|
||||
---
|
||||
|
||||
<h2>📖 description:</h2>
|
||||
<p>
|
||||
sleep as android status is my solution for wake/sleep state within HA. it listens for the Sleep As Android MQTT messages, so it does require being on the same network. as of 0.0.4, buttons that link with the companion app have been added.
|
||||
</p>
|
||||
## what it does
|
||||
|
||||
<h3>🧱 this integration will create:</h3>
|
||||
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.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<details>
|
||||
<summary><strong>📡 8 sensors</strong></summary>
|
||||
## sensors
|
||||
|
||||
| Sensor | Description |
|
||||
| ------ | ----------- |
|
||||
| message received | shows the last raw MQTT event payload |
|
||||
| wake status | indicates awake or asleep based on your sleep stage |
|
||||
| sound | snore, talk, cough, and other sound events |
|
||||
| disturbance | reports apnea and antisnoring events |
|
||||
| **next alarm** | upcoming alarm time and label; stores the last ten alarms in attributes |
|
||||
| alarm | alarm related events such as snooze or dismiss |
|
||||
| lullaby | lullaby status |
|
||||
| sleep tracking | whether sleep tracking is active or paused |
|
||||
| sleep stage | current sleep stage from Sleep As Android |
|
||||
| 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 tracking | whether tracking is active or paused |
|
||||
| alarm event | alarm events like snooze, dismiss, skip |
|
||||
| sound | snore, talk, cough, and other detected sounds |
|
||||
| disturbance | apnea and anti-snoring events |
|
||||
| lullaby | lullaby playback status |
|
||||
| state | raw event from last mqtt message |
|
||||
|
||||
<p>the wake status sensor adjusts automatically based on the defined awake and asleep states.</p>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details>
|
||||
<summary><strong>🎛️ 8 buttons *only if mobile_app selected</strong></summary>
|
||||
<ul>
|
||||
<li>alarm dismiss</li>
|
||||
<li>alarm snooze</li>
|
||||
<li>lullaby stop</li>
|
||||
<li>sleep tracking pause</li>
|
||||
<li>sleep tracking resume</li>
|
||||
<li>sleep tracking start</li>
|
||||
<li>sleep tracking start with optimal alarm</li>
|
||||
<li>sleep tracking stop</li>
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details>
|
||||
<summary><strong>🛠️ 1 service</strong></summary>
|
||||
<pre>
|
||||
service: sleepd.sleepd_example_alarm_set
|
||||
data:
|
||||
message: Example Message!
|
||||
day: monday
|
||||
hour: 7
|
||||
minute: 30
|
||||
</pre>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details>
|
||||
<summary><strong>🔗 1 device per user</strong></summary>
|
||||
<p>one HA device is created per configured user instance to link sensors, services, and buttons.</p>
|
||||
</details>
|
||||
</li>
|
||||
</ul>
|
||||
## buttons
|
||||
|
||||
*requires home assistant companion app*
|
||||
|
||||
- alarm dismiss / snooze
|
||||
- lullaby stop
|
||||
- sleep tracking start / stop / pause / resume
|
||||
- sleep tracking start with smart alarm
|
||||
|
||||
## installation
|
||||
|
||||
1. add this repo to HACS custom repositories:
|
||||
```
|
||||
https://github.com/sudoxnym/sleepd
|
||||
```
|
||||
|
||||
2. search for **sleepd** in HACS and install
|
||||
|
||||
3. restart home assistant
|
||||
|
||||
4. add integration via UI or click below:
|
||||
|
||||
[](https://my.home-assistant.io/redirect/config_flow_start/?domain=sleepd)
|
||||
|
||||
## configuration
|
||||
|
||||
| option | description |
|
||||
|--------|-------------|
|
||||
| name | identifier for this user/device |
|
||||
| topic | mqtt topic (must match sleep as android settings) |
|
||||
| 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) |
|
||||
|
||||
## sleep as android setup
|
||||
|
||||
1. open sleep as android > settings > services > automation > MQTT
|
||||
|
||||
2. connection string format:
|
||||
```
|
||||
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
|
||||
|
||||
4. enable automatic tracking
|
||||
|
||||
## compatible wearables
|
||||
|
||||
tested with:
|
||||
- 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)
|
||||
|
||||
<details>
|
||||
<summary><strong>✅ known working</strong></summary>
|
||||
<ul>
|
||||
<li>📟 **Xiaomi Mi Band 7**</li>
|
||||
<li>📟 **Xiaomi Mi Band 8** and **Mi Band 9** may work, but they have a different os that jumps through hoops to work.</li>
|
||||
<li>⌚ **Garmin Fenix 7X** with garmin alternative, **not** the free one.</li>
|
||||
<li>⌚ **Xiaomi Amazfit GTR3 Pro** — may require root. i am rooted so i just did what's in this guide, but there may be alternative ways to get the key.</li>
|
||||
</ul>
|
||||
</details>
|
||||
<summary>mi band 7 setup with notify</summary>
|
||||
|
||||
<h2>🧪 installation:</h2>
|
||||
<ul>
|
||||
<li>add <code>https://www.github.com/sudoxnym/sleepd</code> to your custom repositories in HACS</li>
|
||||
<li>search and download **sleepd - Sleep As Android status**</li>
|
||||
<li>restart Home Assistant</li>
|
||||
<li>
|
||||
<a href="https://my.home-assistant.io/redirect/config_flow_start/?domain=sleepd">
|
||||
<img src="https://my.home-assistant.io/badges/config_flow_start.svg" alt="add to ha">
|
||||
</a>
|
||||
</li>
|
||||
<li>add integration: **sleepd - Sleep As Android status**</li>
|
||||
</ul>
|
||||
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
|
||||
|
||||
<h2>⚙️ configuration:</h2>
|
||||
<ul>
|
||||
<li>name: name of user</li>
|
||||
<li>topic: MQTT topic from Sleep As Android *MUST MATCH*</li>
|
||||
<li>awake duration: time in seconds in which awake states = true to indicate awake. <b>fixed</b></li>
|
||||
<li>asleep duration: time in seconds in which sleep states = true to indicate asleep. <b>fixed</b></li>
|
||||
<li>awake states: states to indicate being awake</li>
|
||||
<li>asleep states: states to indicate being asleep</li>
|
||||
<li>mobile app: target for buttons <b>requires companion app *OPTIONAL: REQUIRES COMPANION APP*</b></li>
|
||||
</ul>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<p>credit: <a href="https://www.reddit.com/r/miband/comments/15j0rfq/comment/kxlyzc6/">iamfosscad</a></p>
|
||||
|
||||
<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>
|
||||
|
||||
<details>
|
||||
<summary><strong>🔐 extracting the Zepp <code>authKey</code> on a rooted android device</strong></summary>
|
||||
<pre>
|
||||
<summary>zepp auth key extraction (rooted)</summary>
|
||||
|
||||
```bash
|
||||
su
|
||||
cd /data/data/com.huami.watch.hmwatchmanager/databases/
|
||||
ls origin_db_*
|
||||
sqlite3 origin_db_1234567890 "SELECT AUTHKEY FROM DEVICE;"
|
||||
</pre>
|
||||
sqlite3 origin_db_* "SELECT AUTHKEY FROM DEVICE;"
|
||||
```
|
||||
|
||||
<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>
|
||||
## changelog
|
||||
|
||||
<pre>
|
||||
(tcp/ssl)://(MQTT User):(MQTT Pass)@(HA URL):(port)
|
||||
</pre>
|
||||
**1.0.0** - rebranded from saas to sleepd, removed next alarm sensor
|
||||
|
||||
<ul>
|
||||
<li>topic: must match config</li>
|
||||
<li>client id: any unique id</li>
|
||||
</ul>
|
||||
**0.2.1** - fixed manifest error, config reconfigure now works
|
||||
|
||||
<ol start="4">
|
||||
<li>enable automatic tracking</li>
|
||||
<li>sensor: sonar or accelerometer</li>
|
||||
<li>wearables > **Xiaomi Mi Band** > test sensor</li>
|
||||
</ol>
|
||||
**0.2.0** - fixed deprecation warnings for HA 2025.12 (breaking: re-add integration after update)
|
||||
|
||||
<details>
|
||||
<summary><strong>📦 changes</strong></summary>
|
||||
<b>0.2.2</b>
|
||||
<ul>
|
||||
<li>added Next Alarm sensor with alarm label tracking</li>
|
||||
<li>stores up to ten previous alarms in sensor attributes</li>
|
||||
</ul>
|
||||
<b>0.2.1</b>
|
||||
<ul>
|
||||
<li>fixed manifest error preventing config setup</li>
|
||||
<li>fixed fine tuning in the configure section, now changing time or device actually works</li>
|
||||
</ul>
|
||||
**0.1.0** - fixed wake status timing, sound sensor bugs
|
||||
|
||||
<b>0.2.0</b>
|
||||
<ul>
|
||||
<li>added services.yaml to resolve known NoneType error</li>
|
||||
<li>fixed deprecation warnings for future Home Assistant releases</li>
|
||||
<li>breaking changes: remove and re-add existing integration entries after update</li>
|
||||
</ul>
|
||||
---
|
||||
|
||||
<b>0.1.0</b>
|
||||
<ul>
|
||||
<li>fixed wake status timing</li>
|
||||
<li>bug fixes on sound sensor</li>
|
||||
<li>accurate updates to alarmevent, disturbance, sound</li>
|
||||
<li>organized readme</li>
|
||||
</ul>
|
||||
|
||||
<b>0.0.6a</b>
|
||||
<ul>
|
||||
<li>initial beta release</li>
|
||||
<li>added persistent states</li>
|
||||
<li>alarm event sensor attributes</li>
|
||||
</ul>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>🚨 known issues</strong></summary>
|
||||
<p>💬 no known issues at this time.</p>
|
||||
</details>
|
||||
*formerly known as [saas](https://github.com/sudoxnym/saas)*
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@
|
|||
"dependencies": ["mqtt", "mobile_app"],
|
||||
"documentation": "https://www.github.com/sudoxnym/sleepd",
|
||||
"issue_tracker": "https://www.github.com/sudoxnym/sleepd/issues",
|
||||
"version": "0.2.1"
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue