No description
Find a file
2026-02-28 07:50:12 -06:00
.github Add files via upload 2025-04-13 13:24:26 -06:00
brands Add files via upload 2024-05-27 01:11:11 -06:00
custom_components/saas style: lowercase everything 2025-12-07 08:40:08 -06:00
.gitignore Create .gitignore 2024-05-05 20:48:10 -06:00
CODE_OF_CONDUCT.md Add files via upload 2025-04-13 13:15:19 -06:00
CONTRIBUTING.md rebrand to sleepd, remove next alarm sensor 2025-12-07 08:04:02 -06:00
DEPLOY.md rebrand to sleepd, remove next alarm sensor 2025-12-07 08:04:02 -06:00
hacs.json style: lowercase everything 2025-12-07 08:40:08 -06:00
LICENSE Add files via upload 2025-04-13 13:15:19 -06:00
README.md Update README.md 2026-02-28 07:50:12 -06:00

sleepd

real-time sleep state tracking for home assistant

HACS Custom License

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.


features

  • wake status sensorawake or asleep based on configurable thresholds
  • sleep stage tracking — light, deep, rem, awake
  • alarm controls — dismiss, snooze, skip via HA buttons
  • sound detection — snore, talk, cough events
  • lullaby control — playback status and stop button
  • disturbance alerts — apnea and anti-snoring events

📱 compatible apps

📊 sensors

sensor description
wake status awake or asleep based on configurable states and durations
sleep stage current stage (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

🎮 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 to hacs

    open your hacs

  2. search for sleepd in HACS and install

  3. restart home assistant

  4. add integration via UI:

    Add Integration

option 2: manual

  1. copy custom_components/saas to your HA custom_components directory
  2. restart home assistant

📡 mqtt setup

sleepd expects json messages with an event field:

{"event": "sleep_tracking_started"}
{"event": "sleep_tracking_stopped"}
{"event": "alarm_alert_start", "value1": "1733580000000"}
{"event": "light_sleep"}
{"event": "deep_sleep"}
{"event": "rem"}
📲 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

🛌 sleep as android setup

  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

⚙️ 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

made by sudoxnym

formerly known as saas -sleep as android status the app is capable of working with any mqtt sleep app now