Skip to content

sudoxnym/saas

add to hacs

🌙 saas - Sleep As Android status

🚨 0.2.0 breaking changes 🚨

due to changes in **Home Assistant** 2025.12, you **must** remove your existing **SAAS** integration entries and re-add them after updating to this version.

📖 description:

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.

🧱 this integration will create:

  • 📡 9 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
      <p>the wake status sensor adjusts automatically based on the defined awake and asleep states.</p>
    </details>
    
  • 🎛️ 8 buttons *only if mobile_app selected
    • alarm dismiss
    • alarm snooze
    • lullaby stop
    • sleep tracking pause
    • sleep tracking resume
    • sleep tracking start
    • sleep tracking start with optimal alarm
    • sleep tracking stop
  • 🛠️ 1 service
    service: saas.saas_example_alarm_set
    data:
      message: Example Message!
      day: monday
      hour: 7
      minute: 30
          
  • 🔗 1 device per user

    one HA device is created per configured user instance to link sensors, services, and buttons.

✅ known working
  • 📟 **Xiaomi Mi Band 7**
  • 📟 **Xiaomi Mi Band 8** and **Mi Band 9** may work, but they have a different os that jumps through hoops to work.
  • ⌚ **Garmin Fenix 7X** with garmin alternative, **not** the free one.
  • ⌚ **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.

🧪 installation:

  • 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 to ha
  • add integration: **SAAS - Sleep As Android status**

⚙️ configuration:

  • name: name of user
  • topic: MQTT topic from Sleep As Android *MUST MATCH*
  • awake duration: time in seconds in which awake states = true to indicate awake. fixed
  • asleep duration: time in seconds in which sleep states = true to indicate asleep. fixed
  • awake states: states to indicate being awake
  • asleep states: states to indicate being asleep
  • mobile app: target for buttons requires companion app *OPTIONAL: REQUIRES COMPANION APP*
📲 set up Notify for Mi Band 7
  1. pair **Mi Band 7** as you normally would with Mi Fitness
  2. obtain auth key for Notify app using ADB
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}'
  

credit: iamfosscad

  1. uninstall **Mi Fitness**
  2. download/install Notify for Mi Band
  3. follow prompts, input auth key, select Mi Fitness is not installed
  4. enable Sleep As Android in Notify settings
🔐 extracting the Zepp authKey on a rooted android device
su
cd /data/data/com.huami.watch.hmwatchmanager/databases/
ls origin_db_*
sqlite3 origin_db_1234567890 "SELECT AUTHKEY FROM DEVICE;"
  
  • ⚠️ do not unpair before extracting
  • use with caution – root required
  • modified apps are available on GeekDoing and FreeMyBand
  1. open the app and follow setup
  2. settings wheel > services > automation > MQTT
(tcp/ssl)://(MQTT User):(MQTT Pass)@(HA URL):(port)
  • topic: must match config
  • client id: any unique id
  1. enable automatic tracking
  2. sensor: sonar or accelerometer
  3. wearables > **Xiaomi Mi Band** > test sensor
📦 changes 0.2.2
  • added Next Alarm sensor with alarm label tracking
  • stores up to ten previous alarms in sensor attributes
0.2.1
  • fixed manifest error preventing config setup
  • fixed fine tuning in the configure section, now changing time or device actually works

0.2.0

  • added services.yaml to resolve known NoneType error
  • fixed deprecation warnings for future Home Assistant releases
  • breaking changes: remove and re-add existing integration entries after update

0.1.0

  • fixed wake status timing
  • bug fixes on sound sensor
  • accurate updates to alarmevent, disturbance, sound
  • organized readme

0.0.6a

  • initial beta release
  • added persistent states
  • alarm event sensor attributes
🚨 known issues

💬 no known issues at this time.

About

SAAS - Sleep As Android Status

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages