Screen time and Health Connect from your Android phone in Home Assistant, paired with a QR code, no broker (open source)

I built an open source Android app plus a HACS integration that get two things into Home Assistant that otherwise need workarounds:

Screen time. How long you used the phone today and yesterday, and which app took most of it, straight from Android’s usage statistics (the same numbers as Digital Wellbeing). The Companion app cannot read this, and the usual answers are Tasker, or history_stats over the interactive sensor. This one is a sensor for today, one for yesterday, one for the most used app, the top five apps with their minutes as an attribute, and long-term statistics per day so you can see which weeks the phone won.

Health Connect. 33 data types: steps, distance, calories, sleep, heart rate, resting heart rate, HRV, weight, blood pressure, glucose, oxygen saturation, body temperature, hydration, workouts, mindfulness, cycle tracking, and more. Day totals come from Health Connect’s own deduplicated aggregate, so a phone plus a watch does not double count.

Setting it up takes two minutes

  1. Install Life Dashboard from HACS: add owen282000/life-dashboard-ha as a custom repository for now, the pull request to the default list is in the queue.
  2. Add the integration. It asks for a name, shows the address your browser is using (change it if the phone should use another one, or tick Home Assistant Cloud), then shows a QR code.
  3. Point the phone’s camera at the code, or use the scan button in the app. The app shows what it is about to fill in, you tap Pair, then Sync now.

No broker, no ports, no YAML. Every payload is signed with HMAC-SHA256 over a secret the integration generated, and there is no switch to turn that off; a leaked URL is useless. Give it your home network address and the data never leaves your network.

History that is actually history

A sensor can only hold now. The integration also writes long-term statistics with the real dates: day totals for steps, distance, calories, sleep, exercise, mindfulness, hydration and screen time, and hourly mean/min/max for heart rate and the other measured values. The app has a backfill: this is a year of my own Health Connect data, five months after I switched phones, in the dashboard the integration ships to start from.

The device page, the pairing dialog and the statistics cards are in the integration’s README; the forum lets a new account post one picture, so this is the one.

If you would rather not use the integration

The app also does MQTT with Discovery (point it at your broker, sensors appear under one device, screen time included) and a plain webhook to an automation trigger with a published JSON Schema. Pick one route; all three carry the same payload.

The honest list

  • Android 8 or newer; Health Connect for the health part, the usage access permission for screen time. APK from GitHub Releases, signed, with build provenance you can verify. The F-Droid submission is in review, Google Play is coming.
  • There is an iOS app with the same payload (owen282000/life-dashboard-companion-app-ios). It reaches Home Assistant through MQTT today; the integration does not accept it yet, that is issue 1 on the integration repo.
  • Aggressive battery management (Samsung, Xiaomi, OnePlus and friends) can stop background syncs silently. The app’s docs tell you what to set; the Logs tab shows every delivery attempt with Home Assistant’s answer.
  • No cloud, no trackers, no third-party SDKs, MIT licensed.

Links: integration · Android app

If you try it, I would like to hear what works and what does not, here or on GitHub. And if you would be willing to test the Google Play version when it is ready (a closed test needs a handful of testers for two weeks), say so and I will get back to you.

Small update, since a lot has happened in the last ten days; app 1.20.0 and integration 0.7.0 are out.

The biggest change is that it now also works the other way around. If you have a scale or blood pressure monitor connected to HA, those measurements can now be written into Health Connect on your phone, so they show up in Samsung Health or Google Health as well. This came from a request after I posted about the app on Reddit, and I’m pretty happy with how it turned out. You choose which entities get sent per phone in the integration’s options, and every type asks for its own write permission on the phone, so nothing gets written that you didn’t turn on yourself.

Two smaller things that came with it: if you run the MQTT route with two phones on one broker, you can now give each phone a name (Advanced > Phone name) so they each get their own device in HA. And the Receive row in the app tells you what’s wrong when something is off, like a lost pairing, an integration that’s too old, or no entities mapped yet.

F-Droid and the HACS default list are both still in review.

Questions, ideas or bugs are welcome here or on GitHub!