This integration works best with a Xioami MiBand (7 or older) mixed with the Notify app and Sleep As Android configured.
Garmin Fenix 7X with Garmin Alternative, NOT the free one.
Message Received *State
Wake Status
Sound
Disturbance
Alarm
Lullaby
Sleep Tracking
Sleep Stage
This should intelligently and dynamically allow for state changes in the Wake Status Sensor.
Alarm Dismiss
Alarm Snooze
Lullaby Stop
Sleep Tracking Pause
Sleep Tracking Resume
Sleep Tracking Start
Sleep Tracking Start with Optimal Alarm
Sleep Tracking Stop
Set alarm service
service: saas.saas_example_alarm_set data: message: Example Message! day: monday hour: 7 minute: 30
Add https://www.github.com/sudoxnym/saas to your Custom Repositories in HACS
Search and Download SAAS - Sleep As Android Status
Restart Home Assistant
Add Integration: SAAS - Sleep As Android Status
Name: Name of user
Topic: MQTT Topic from Sleep As Android
QoS: Quality of Service
Awake Duration: This is for tuning. Time in seconds in which awake states = true to indicate awake. Sensor usually updates within 30 seconds or so after the duration, not entirely sure why the delay. FIXED
Asleep Duration: This is for tuning. Time in seconds in which sleep states = true to indicate asleep. Sensor usually updates within 30 seconds or so after the duration, not entirely sure why the delay. FIXED
Awake States: States to indicate being awake
Asleep States: States to indicate being asleep
Mobile App: Target for buttons REQUIRES COMPANION APP
Set Up Notify for MiBand 7 (as of August 10, 2024)
2. Obtain auth key for Notify app. Connect to pc with usb and open your adb SDK Platform-Pools, or if you're more advanced, connect wirelessly
Windows:
2a. Open folder with adb in it
2b. Right click a blank spot within the folder
2c. Open in terminal
2d. Ensure usb debugging is on on your android and plug it into the pc.
2e.
./adb shell2f.
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}'2g. Copy/clipboard the output. Disconnect phone, close ADB.
Credit: iamfosscad
3. Uninstall Mi Fitness
4. Download/Install Notify for Mi Band (up to 7)
5. Follow the prompts, enable any permission it asks for, create the profile, input Auth Key, and select Mi Fitness is not installed
6. Open the hamburger menu on the top left
7. Search > Search for "Sleep"
8. Turn on Sleep as Android
9. Enjoy
1. Open the app and follow setup
2. Settings wheel in top right > Services > Automation
3. MQTT
3a. URL
(tcp/ssl)://(MQTT User):(MQTT Pass)@(HA URL):(port)3b. Topic > something recognizable. You need this exact topic in HA Integration Config.
3c. Client ID > I set the same, not sure if it should be, but it works.
3d. Test > Wait for "Success" toast message
4. Back to app settings > Sleep tracking >
4a. Automatic Sleep Tracking > After fall asleep
4b. Sensor > Sonar (if placing phone on a bedside table) Accelerometer (if placing on bed next to you)
4c. Wearables >
4c1. Wearables > Xiaomi Mi Band > Test sensor
4c2. Heart rate monitoring (optional)
4d. Pair tracking (optional)
5. Enjoy (optional)
0.0.6a
Initial Beta Release
Added persistant states through HA restart
Added attributes for the Alarm Event sensor
0.1.0
Fixed Wake Status Timing (HUGE)
Fixed bug with Sound sensor
Modified AlarmEvent, Disturbance, and Sound sensors to update to None accurately
Organized Readme.md
Error in logs:
Logger: homeassistant.helpers.service Source: /usr/src/homeassistant/homeassistant/helpers/service.py:708 First occurred: 3:55:19 PM (1 occurrences) Last logged: 3:55:19 PMNo known effects. Just an error message, everything works as expected. Please report any issues.Failed to load integration: saas NoneType: None
This is my first integration.