android
android copied to clipboard
Implement Health Connect Sensors
Summary
Implementing health connect API to create various sensors.
Screenshots
Link to pull request in Documentation repository
TODO
Any other notes
Issue #2537
I have just implemented a few data points from the Health Connect API. Still a lot more work to do. Creating a pull request to set the task in motion and getting others opinions. List of sensors that can be implemented: https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/package-summary#classes Further action required -
- Add a privacy policy page if required
- Submit form for approval
According to the nature of Home Assistant, it can come under Fitness and Wellness use case
This is awesome but i think will require some thought about how to get required stuff from Google before/after the PR is accepted/merged. I suppose maybe its best to first try for approval and go from there? Honestly speaking its tough to say what Google will say the app can qualify for. For example we do not qualify for all the permissions Tasker is approved for, otherwise we would be able to restore our call number sensor.
This is awesome but i think will require some thought about how to get required stuff from Google before/after the PR is accepted/merged. I suppose maybe its best to first try for approval and go from there? Honestly speaking its tough to say what Google will say the app can qualify for. For example we do not qualify for all the permissions Tasker is approved for, otherwise we would be able to restore our call number sensor.
In order to actually request the permissions we need to upload a version that requests the permissions. There isn't a way without merging to start the approval requests.
initial tests look great!
lots of decimals returned for calories burned....strangely it does not match the amount we get from health services where the data is taken from the watch directly...maybe fitbit is doing its own thing?
https://github.com/home-assistant/android/blob/master/wear/src/main/java/io/homeassistant/companion/android/sensors/HealthServicesSensorManager.kt#L359
lots of decimals returned for calories burned....strangely it does not match the amount we get from health services where the data is taken from the watch directly...maybe fitbit is doing its own thing?
Fixed the precision to 2 decimals. And can you check in the Health Connect logs where the additional 3 kcal is coming from? Some other app might be writing into health connect or maybe my logic to calculate total calories is incorrect.
Another requirement for getting approval is displaying privacy policy when clicked on Health Connect permissions page. For this, we can either
- add code at the beginning of onCreate in LaunchActivity to receive intent and redirect directly to privacy policy webpage
- or redirect user to the settings page where there the privacy policy item is listed.
And can you check in the Health Connect logs where the additional 3 kcal is coming from? Some other app might be writing into health connect or maybe my logic to calculate total calories is incorrect.
the difference is expected there actually, the health services sensor update every 15 minutes however I think fitbit will sync once an hour so I wouldnt expect them to have the same value but should be fairly close.
Here is an overnight graph for comparison
health connect
health services
Another requirement for getting approval is displaying privacy policy when clicked on Health Connect permissions page. For this, we can either
- add code at the beginning of onCreate in LaunchActivity to receive intent and redirect directly to privacy policy webpage
- or redirect user to the settings page where there the privacy policy item is listed.
personally I am indifferent on where to put it however we already have a privacy policy mention in our settings page so I think another one can't hurt. Can we maybe combine them?
On clicking privacy policy on Health Connect permission page, it will redirect to Home Assistant privacy policy webpage
I see a lot of chat about google approval. Are we likely to see this in the app soon? I'm excited to get some fitness data after This Google Fit Integration Said the fit API has been deprecated (for new users at least).
This PR is failing to push to the play store as we now need to submit for approval. Have requested the correct people to do so for us so hopefully we will hear back soon. Until then this will be holding up PR's being merged and sent to the play store until resolved.
According to the docs the app should be able to publish to the Play Store before approval. The users see a different permission popup if there is no approval.
According to the docs the app should be able to publish to the Play Store before approval. The users see a different permission popup if there is no approval.
yea the action is failing suggesting thats not the case :) the action attempts to push to our internal beta track which is where this is failing
[16:14:57***: Google Api Error: Invalid request - You need approval to use the following Health Connect permissions in your app: android.permission.health.READ_ACTIVE_CALORIES_BURNED,android.permission.health.READ_TOTAL_CALORIES_BURNED,android.permission.health.READ_WEIGHT. Learn more: https://support.google.com/googleplay/android-developer/answer/12991134
I believe by publish they mean an app that has never published and does not have health connect features in it which we are already a published app.
BTW if approval with Google is successful we were thinking that due to https://github.com/home-assistant/android/pull/4552 we shoudl probably go for adding a heart rate sensor next to bring the data back to some extent
Health connect form submitted, now to wait 7-14 business days. Hopefully we wont see too much back and forth here.
Can't wait to see all other sensors implemented after this succeeds.
@dshokouhi hoping you might have an update for us?
@wwelles unfortunately no updates from Google yet. Today is actually the last business day for them to respond. I also just noticed that they changed their policy and those changes take place TOMORROW (what are the odds right? π )
https://support.google.com/googleplay/android-developer/answer/9888170?sjid=4865781794872932585-NC
Weβre updating our [Health Connect policy](https://support.google.com/googleplay/android-developer/answer/13986130) to streamline the Health Connect application process and align with the Health Apps policy. The existing form-based application will be replaced with a new Play Console declaration later this year. (effective August 31, 2024)
We actually already have approval for Health Apps declaration as we are using the Body Sensor permission for Heart Rate on Wear OS and Activity Detection on the phone so hopefully the new process will be easier and faster. Our current approval is for Activity and Fitness which is very similar to Fitness and Wellness category we initially applied for.
Given that once approved we have mostly everything lined up to push the next beta. We actually have another deadline that is up TODAY that will also impact the releases so a lot is held up here.
Appreciate all the hard work that's gone into this, hopefully they'll update us soon!
Hey all just wanted to give a quick update. We were finally able to submit our health connect declaration to Google last night and its in reviewnow. Given we get approval, next weeks beta (2024.10.2-full) should contain the new sensors!
We have received approval for the set of health connect permissions in this PR! So next weeks beta (2024.10.2.-full) will contain the new sensors, once approved of course. Thanks again for the PR @psbankar π ! For now I will leave #2537 open so the discussion on adding remaining sensors can continue there. (These are a good Hacktoberfest item for anyone interested, speaking of which these sensors can also use a companion app docs update π )
What new beta? the home assistant beta (2024.10.2.-full)?
Do we have any new good news?
@mapsindustrial as mentioned twice already the build is now waiting for approval from Google and once done it will be part of the apps beta program.
https://play.google.com/apps/testing/io.homeassistant.companion.android