Unofficial Home Assistant integration that pulls health & fitness data (steps, heart rate, sleep, vitality, SpO₂, weight, stand hours …) from the Xiaomi Mi Fitness / MiHealth cloud. Data is read at the account level — whatever your Xiaomi devices (bands, scales, …) sync to Mi Fitness shows up, regardless of which device produced it.
⚠️ Disclaimer — educational / unofficial. Not affiliated with, authorized, or endorsed by Xiaomi. It talks to a private cloud API by reusing your own account session, which may break at any time and may be against Xiaomi's Terms of Service. Use at your own risk, with your own account only.
- Sensors: steps, distance, calories, heart rate (avg/max/min/resting), sleep (duration, stages, quality, chronotype), vitality, stand hours, SpO₂, weight.
- Silent token refresh using
passToken— survivesserviceTokenexpiry without re-doing 2FA. - Custom Lovelace cards for activity and sleep (in
www/).
- HACS → ⋮ → Custom repositories.
- Add
https://github.com/batareya16/MiFitnessHassas category Integration. - Install Mi Fitness, then restart Home Assistant.
- Settings → Devices & Services → Add Integration → Mi Fitness.
Copy custom_components/mi_fitness/ into your HA config/custom_components/
and restart.
Two authentication paths in the config flow:
Enter your Xiaomi account email/phone and password. If 2FA is enabled, a code
is emailed to you and entered in the next step. The integration stores a
passToken so it can refresh expired session tokens silently afterwards.
Advanced fallback for accounts where automated login fails. Supply credentials obtained from your own Mi Fitness account session:
ssecurity,userId,cUserId— from theserviceLoginAuth2responsepassToken— from theserviceLoginAuth2Set-CookieheaderserviceToken— from the STSSet-Cookieheader
Paste them into the form. passToken is optional but strongly recommended (it
enables silent refresh).
The integration ships custom cards (in
custom_components/mi_fitness/www/) and
registers them automatically — no manual resource setup needed.
Just add them to a dashboard:
type: custom:mi-fitness-sleep-card
type: custom:mi-fitness-sleep-streak-card
goal_hours: 7
goal_minutes: 30
name: Sleep Goal
type: custom:mi-fitness-activity-card
step_goal: 6000
type: custom:mi-fitness-activity-streak-card
step_goal: 6000
name: Step GoalThe account is detected automatically from your entities — no user_id needed.
Only set it to disambiguate when you have more than one Mi Fitness account
configured:
type: custom:mi-fitness-sleep-card
user_id: "1234567890" # optional; the suffix in sensor.mi_fitness_<user_id>_…To find it manually: Developer Tools → States, filter
mi_fitness— the number in the entity id (e.g.sensor.mi_fitness_1234567890_steps_today) is youruser_id.
After updating the integration, hard-refresh the browser (Ctrl+Shift+R) so the new card code loads.
No credentials or device identifiers are committed to this repository. Your
tokens are stored only in your own Home Assistant instance
(.storage/core.config_entries) — never commit your HA config.