home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.23k stars 623 forks source link

Android Health Connect API #2537

Open 00pi opened 2 years ago

00pi commented 2 years ago

Is your feature request related to a problem? Please describe. For years I tried to sync my Xiaomi Smart Scale 2 to my Polar Flow account. Interfacing it with HA though ESPhome works as a charm, but there is no official write enabled API provided by Polar. Neither do I like to use any of the available fitness data syncing services such as SyncMyTracks as they request my login credentials and are subject to blockage from the providers at any time. Nor have I found any suitable service to directly populate my data and sync it to Polar Flow

Describe the solution you'd like Check whether the Health Connect API can be implemented in the Android Companion App (or to avoid potential conflicts with Google: provide a separate Home Assistant Health Companion App). This would provide an interface to and from any fitness app that is going to join the Helath Connect API. And due to Googles power on the market, I expect them to join sooner or later.

Describe alternatives you've considered, if any native Integrations for health related cloud services are not widely available, are subject to API limitations or blocking (https://github.com/home-assistant/core/issues/53833) were based on web scraping and thus removed from HA (https://github.com/home-assistant/architecture/issues/252)

Additional context quote from (https://developer.android.com/guide/health-and-fitness/health-connect) "Health Connect is an Android API and platform. It unifies data from multiple devices and apps into an ecosystem. For Android developers, it provides a single interface for reading and writing a user’s health and fitness data. For Android users, it offers a place for control over which apps have read and/or write access to different types of data. Health Connect also provides on-device storage. [...] Health Connect meets that need by unifying access to health and fitness data and empowering users to have control over their data. It provides users with a single way to access an overview of the health and fitness data they’re storing and sharing, along with access to privacy controls. Health Connect is an API that enables all our devices and apps across our ecosystem to work together."

dshokouhi commented 2 years ago

I don't see any current apps that support this API yet, lets try to find some apps that will supply the API with data so we can read from them. I know we can write data and then read it but we are not a fitness app so it wouldn't make sense for us to write the data. If we find any compatible apps lets comment on here so we can investigate this closer. From the apps perspective we will probably do sensor tracking to start.

jpelgrom commented 2 years ago

Would Home Assistant even be eligible to connect? While it might be possible to describe the functionality as something that is compliant, due to HA's nature the user can do anything with the data which is explicitly not allowed: https://developer.android.com/guide/health-and-fitness/health-connect-guidelines/health-connect-policy-requirement-faqs#frequently_asked_questions_faq

What are the approved use cases for Health Connect permissions? For applications requesting access to any Health Connect permissions, approved use cases include fitness and wellness, rewards, fitness coaching, corporate wellness, medical care, health research, and games. Applications granted access to this permission may not extend its use to undisclosed or non-permitted purposes.

dshokouhi commented 2 years ago

We could probably try to make an argument for personal health research :)

dshokouhi commented 2 years ago

ok looks like first app on my phone to support this is Sleep as Android, no surprised there lol.

acesyde commented 1 year ago

Hi there,

Currently these apps support the Android Health Connect API

jonathan-morton commented 1 year ago

The beta came out with support for many more apps as well https://android-developers.googleblog.com/2022/11/leading-health-and-fitness-apps-roll-out-health-connect-integrations.html

dshokouhi commented 1 year ago

right now the main question for us is, do we qualify for this API. Not every app is eligible

https://developer.android.com/guide/health-and-fitness/health-connect-guidelines/health-connect-policy-requirement-faqs

I do not know if we qualify for an approved use case here 🤔

Also seems like we will need a security assessment as well.

siikanen commented 1 year ago

Any updates on this one? I'd be very interested importing my health connect data to HA and I'm positive many others would be as well

dshokouhi commented 1 year ago

Any updates on this one?

no updates, until we know we qualify for the API we will probably not move forward with development.

With that said we do have Health Services sensors which allow you to pull the same data directly off a wearable. They are part of the same health API and also provide data to it.

ndm13 commented 1 year ago

Just connected Fitbit since that's now supported, and noticed that their integration is write only. Maybe a read only HA integration would be more likely to be accepted?

dshokouhi commented 1 year ago

the security and permission requirements are the same, honestly its tough to tell before we attempt to do approval

siikanen commented 1 year ago

Is there any ongoing attempt to get the approval or are you planning to? If there's anything I can help with, let me know

dshokouhi commented 1 year ago

Is there any ongoing attempt to get the approval or are you planning to?

we are all volunteers and work on whatever it is we want, you are more than welcome to read the docs and see what needs to be done.

pacjo commented 1 year ago

How about using metriport as an alternative?

dshokouhi commented 1 year ago

How about using metriport as an alternative?

that looks like something that should be integrated into Home Assistant core as opposed to the app directly.

pacjo commented 1 year ago

You're probably right. I will check if issue like this is already open and if not open one.

dshokouhi commented 1 year ago

You're probably right. I will check if issue like this is already open and if not open one.

you should not open an issue with HA core, instead a feature request on the forums.

https://community.home-assistant.io/c/feature-requests/13

Hedda commented 1 year ago

FYI, Google’s official Android Developers Blog has a new headlining post about Withings migrating to use Health Connect:

https://android-developers.googleblog.com/2023/03/withings-reduces-data-sync-code-with--health-and-fitness-api-health-connect.html

Withings reduces 50% of its data sync code by streamlining health and fitness API integrations with Health Connect

PhillipRt commented 1 year ago

All my fitness related apps are now connected to Health connect. Samsung Health, Google fit, Fitbit, Whoop. Implementing a read snyc would be great for a lot of my automations

Nafania commented 9 months ago

interested in this as well as all my android apps reports data through health api

Webbeh commented 2 months ago

OnePlus oHealth syncs to Health Connect as well, and with Google Fit deprecating its API, this is becoming a must have.