Update README.md

added GTR Mini
This commit is contained in:
sudoxnym 2025-04-13 12:59:27 -06:00 committed by GitHub
parent aeca762661
commit 9321e724c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

256
README.md
View file

@ -1,34 +1,61 @@
[![Add to HACS](https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge&logo=home%20assistant&labelColor=202020&color=41BDF5)](https://hacs.xyz/docs/faq/custom_repositories) <p align="center">
<h1>SAAS - Sleep As Android Status</h1> <a href="https://hacs.xyz/docs/faq/custom_repositories">
<h2>Description:</h2> <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">
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.</br> </a>
<h4>This integration works best with a Xioami MiBand (7 or older) mixed with the Notify app and Sleep As Android configured.</h4> </p>
<h3>Known working:</h3>
Xioami Mi Band 7, 8 and 9 may work, but they have a different os that jumps through hoops to work.</br>
Garmin Fenix 7X with Garmin Alternative, <b>NOT</b> the free one.</br>
<h3>This integration will create 8 Sensors, 8 Buttons, 1 service, and 1 device per user:</h3>
<h3>Sensors</h3>
Message Received *State</br>
Wake Status</br>
Sound</br>
Disturbance</br>
Alarm</br>
Lullaby</br>
Sleep Tracking</br>
Sleep Stage</br></br>
This should intelligently and dynamically allow for state changes in the Wake Status Sensor.</br></br>
<h3>Buttons</h3>
Alarm Dismiss</br>
Alarm Snooze</br>
Lullaby Stop</br>
Sleep Tracking Pause</br>
Sleep Tracking Resume</br>
Sleep Tracking Start</br>
Sleep Tracking Start with Optimal Alarm</br>
Sleep Tracking Stop</br>
<h3>Service</h3> <h1>🌙 SAAS - Sleep As Android Status</h1>
Set alarm service</br>
<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>
<h4>💡 This integration works best with a Xioami MiBand (7 or older) mixed with the Notify app and Sleep As Android configured.</h4>
<h3>✅ Known working:</h3>
<ul>
<li>📟 Xioami Mi Band 7</li>
<li>📟 Xioami Mi Band 8 and 9 may work, but they have a different os that jumps through hoops to work.</li>
<li>⌚ Garmin Fenix 7X with Garmin Alternative, <b>NOT</b> the free one.</li>
<li>⌚ Xioami Amazfit GTR Mini, 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>
<h3>🧱 This integration will create:</h3>
<ul>
<li>8 Sensors</li>
<li>8 Buttons</li>
<li>1 Service</li>
<li>1 Device per user</li>
</ul>
<h3>📡 Sensors</h3>
<ul>
<li>Message Received *State</li>
<li>Wake Status</li>
<li>Sound</li>
<li>Disturbance</li>
<li>Alarm</li>
<li>Lullaby</li>
<li>Sleep Tracking</li>
<li>Sleep Stage</li>
</ul>
<p>This should intelligently and dynamically allow for state changes in the Wake Status Sensor.</p>
<h3>🎛️ Buttons</h3>
<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>
<h3>🛠️ Service</h3>
<pre> <pre>
service: saas.saas_example_alarm_set service: saas.saas_example_alarm_set
data: data:
@ -38,87 +65,114 @@ data:
minute: 30 minute: 30
</pre> </pre>
<h2>Installation:</h2> <h2>🧪 Installation:</h2>
<ul>
<li>Add https://www.github.com/sudoxnym/saas to your Custom Repositories in HACS</li>
<li>Search and Download SAAS - Sleep As Android Status</li>
<li>Restart Home Assistant</li>
<li>
<a href="https://my.home-assistant.io/redirect/config_flow_start/?domain=saas">
<img src="https://my.home-assistant.io/badges/config_flow_start.svg" alt="Add to HA">
</a>
</li>
<li>Add Integration: SAAS - Sleep As Android Status</li>
</ul>
Add https://www.github.com/sudoxnym/saas to your Custom Repositories in HACS</br> <h2>⚙️ Configuration:</h2>
<ul>
<li>Name: Name of user</li>
<li>Topic: MQTT Topic from Sleep As Android</li>
<li>QoS: Quality of Service</li>
<li>Awake Duration: Time in seconds in which awake states = true to indicate awake. <s>Sensor usually updates within 30 seconds or so after the duration, not entirely sure why the delay.</s> <b>FIXED</b></li>
<li>Asleep Duration: Time in seconds in which sleep states = true to indicate asleep. <s>Sensor usually updates within 30 seconds or so after the duration, not entirely sure why the delay.</s> <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</b></li>
</ul>
Search and Download SAAS - Sleep As Android Status</br> <details>
Restart Home Assistant</br> <summary><strong>📲 Set Up Notify for Mi Band 7</strong></summary>
[![Add To My Home Assistant](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=saas)<br> <ol>
Add Integration: SAAS - Sleep As Android Status</br></br> <li>Pair MiBand 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>
<h2>Configuration:</h2> <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>
Name: Name of user</br> <p>Credit: <a href="https://www.reddit.com/r/miband/comments/15j0rfq/comment/kxlyzc6/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button">iamfosscad</a></p>
Topic: MQTT Topic from Sleep As Android</br>
QoS: Quality of Service</br></br>
Awake Duration: This is for tuning. Time in seconds in which awake states = true to indicate awake. <s>Sensor usually updates within 30 seconds or so after the duration, not entirely sure why the delay.</s> <b>FIXED</b></br> <ol start="3">
Asleep Duration: This is for tuning. Time in seconds in which sleep states = true to indicate asleep. <s>Sensor usually updates within 30 seconds or so after the duration, not entirely sure why the delay.</s> <b>FIXED</b></br> <li>Uninstall Mi Fitness</li>
Awake States: States to indicate being awake</br> <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>
Asleep States: States to indicate being asleep</br> <li>Follow prompts, input auth key, select Mi Fitness is not installed</li>
Mobile App: Target for buttons <b>REQUIRES COMPANION APP</b></br></br> <li>Enable Sleep as Android in Notify settings</li>
</ol>
</details>
<h3>Set Up Notify for <a href="https://www.amazon.com/Xiaomi-Activity-Tracker-High-Res-Bluetooth/dp/B0B2DK5YCP">MiBand 7</a> (as of August 10, 2024)</h3> <details>
1. Pair MiBand 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> app </br> <summary><strong>🔐 Extracting the Zepp <code>authKey</code> on a Rooted Android Device</strong></summary>
2. Obtain auth key for Notify app. Connect to pc with usb and open your adb <a href="https://developer.android.com/tools/releases/platform-tools">SDK Platform-Pools</a>, or if you're more advanced, connect wirelessly</br> <pre>
Windows:</br> su
&nbsp;&nbsp;2a. Open folder with adb in it</br> cd /data/data/com.huami.watch.hmwatchmanager/databases/
&nbsp;&nbsp;2b. Right click a blank spot within the folder</br> ls origin_db_*
&nbsp;&nbsp;2c. Open in terminal</br> sqlite3 origin_db_1234567890 "SELECT AUTHKEY FROM DEVICE;"
&nbsp;&nbsp;2d. Ensure usb debugging is on on your android and plug it into the pc.</br> </pre>
&nbsp;&nbsp;2e. <pre>./adb shell</pre>
&nbsp;&nbsp;2f. <pre>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>
&nbsp;&nbsp;2g. Copy/clipboard the output. Disconnect phone, close ADB.</br>
&nbsp;&nbsp;&nbsp;&nbsp; Credit: <a href="https://www.reddit.com/r/miband/comments/15j0rfq/comment/kxlyzc6/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button">iamfosscad</a></br>
3. Uninstall Mi Fitness</br>
4. Download/Install <a href="https://play.google.com/store/apps/details?id=com.mc.miband1&hl=en_US">Notify for Mi Band (up to 7)</a></br>
5. Follow the prompts, enable any permission it asks for, create the profile, input Auth Key, and select Mi Fitness is not installed</br>
6. Open the hamburger menu on the top left</br>
7. Search > Search for "Sleep"</br>
8. Turn on Sleep as Android</br>
9. Enjoy</br></br>
<h3><a href="https://play.google.com/store/apps/details?id=com.urbandroid.sleep&hl=en_US">Sleep as Android</a></h3> <ul>
1. Open the app and follow setup</br> <li>⚠️ Do Not Unpair before extracting</li>
2. Settings wheel in top right > Services > Automation</br> <li>Use with caution root required</li>
3. MQTT</br> <li>Modified apps are available on <a href="https://geekdoing.com">GeekDoing</a> and <a href="https://freemyband.com">freemyband.com</a></li>
&nbsp;&nbsp;3a. URL </ul>
<pre>(tcp/ssl)://(MQTT User):(MQTT Pass)@(HA URL):(port)</pre> </details>
&nbsp;&nbsp;3b. Topic > something recognizable. You need this exact topic in HA Integration Config.</br>
&nbsp;&nbsp;3c. Client ID > I set the same, not sure if it should be, but it works.</br>
&nbsp;&nbsp;3d. Test > Wait for "Success" toast message</br>
4. Back to app settings > Sleep tracking > </br>
&nbsp;&nbsp;4a. Automatic Sleep Tracking > After fall asleep</br>
&nbsp;&nbsp;4b. Sensor > Sonar (if placing phone on a bedside table) Accelerometer (if placing on bed next to you)</br>
&nbsp;&nbsp;4c. Wearables ></br>
&nbsp;&nbsp;&nbsp;&nbsp;4c1. Wearables > Xiaomi Mi Band > Test sensor</br>
&nbsp;&nbsp;&nbsp;&nbsp;4c2. Heart rate monitoring (optional)</br>
&nbsp;&nbsp;4d. Pair tracking (optional)</br>
5. Enjoy (optional)</br></br>
<h2>Changes:</h2> <h3>🛌 <a href="https://play.google.com/store/apps/details?id=com.urbandroid.sleep&hl=en_US">Sleep as Android Setup</a></h3>
<b>0.0.6a</b></br> <ol>
Initial Beta Release</br> <li>Open the app and follow setup</li>
Added persistant states through HA restart</br> <li>Settings wheel > Services > Automation > MQTT</li>
Added attributes for the Alarm Event sensor</br></br> </ol>
<b>0.1.0</b></br>
Fixed Wake Status Timing <b>(HUGE)</b></br>
Fixed bug with Sound sensor</br>
Modified AlarmEvent, Disturbance, and Sound sensors to update to None accurately</br>
Organized Readme.md</br>
<h2>Known issues:</h2> <pre>
Error in logs: (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>
<h2>📦 Changes:</h2>
<b>0.0.6a</b>
<ul>
<li>Initial Beta Release</li>
<li>Added persistent states</li>
<li>Alarm Event sensor attributes</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>
<h2>🚨 Known issues:</h2>
<pre> <pre>
Logger: homeassistant.helpers.service Logger: homeassistant.helpers.service
Source: /usr/src/homeassistant/homeassistant/helpers/service.py:708 Source: /usr/src/homeassistant/homeassistant/helpers/service.py:708
First occurred: 3:55:19 PM (1 occurrences)
Last logged: 3:55:19 PM
Failed to load integration: saas Failed to load integration: saas
NoneType: None</pre> NoneType: None
No known effects. Just an error message, everything works as expected. </pre>
Please report any issues.</br>
This is my first integration. <p>💬 No known effects. Just an error message, everything works as expected.</p>
<p>This is my first integration.</p>