[iOS Feature Request] Apple Healthkit Integration

@fivestones Happy to help, here is a bit more information - I can provide even more if needed.

The URL to use is: https://homeassistanturl/api/webhook/health. Health in my example is what I named the webhook in Node Red, if it’s named something else the name goes here.

For node red export, you should be able to paste it into the import screen (right side menu). This represents the entire flow i’m using.

image

1 Like

Thanks for that info. I’d be happy to add you on as a tester. If you get in touch via the contact link, I can get your email to add to the list.

I’ve been in touch with @akeslo, as a starting point, I’m working on some better documentation, so it’s easier to work with the output data, and to make it clearer how the API Export can be expected to work. I’ll then take some steps to look at direct integration, if that’d still be necessary, since it seems that maniupaliting the JSON output from the app may suffice.

@akeslo @fivestones I’ve added some documentation about the JSON structure on GitHub, and I’ll be continuing to add some more information here.

I think there are a few bugs I’ll need to look into but I can turn some attention toward direct integration now :slight_smile:

If you, or anyone, has any questions or issues, I’d appreciate some feedback.

I’ve also added a Projects list to showcase what folks are building, so if anyone wants to share, I’d be happy to post about it.

1 Like

It would be great if you can create this direct integration for Home Assistant ( a good push for your app too). Although the blog at sixtymeters is useful I think the setup with a webhook in NodeRed is too technical for most of us :sweat_smile:

1 Like

I get that for sure! I’m still working on some updates and optimizations, and I’m incorporating a lot of user feedback. So the ability to directly connect to Home Assistant will be on of the big feature releases, and the ability to configure and sync to multiple URLs, since right now it’s only possible to configure one API configuration :slight_smile:

2 Likes

It would be insteresting also to be able to push data from Auto Export directly to a MQTT broker so any system connected (Home Assistant, Node-red,….) could read those values. How about adding this feature @Lybron ? :wink:

1 Like

Hell again folks,

There have been some delays along the road to finally get here but I have a beta that will post updates to the /api/states/<entity_id> endpoint.

Some of you have been in touch already by email, but if there’s anyone who would like access to the beta and you haven’t been in touch yet, just ping me.

2 Likes

Good news everyone. I’ve released Health Auto Export v6.0 with support for posting data to the Home Assistant entity endpoint and support for publishing to MQTT brokers.

If you run into any issues or have questions or suggestions, you’re welcome to get in touch.

6 Likes

Hey @Lybron … I have tried to get your app to send data to Home Assistant but cannot, I’m getting an error ‘Failed to publish’.

I’m using Nabu Casa (cloud)… maybe that has something to do with it? I’ve also tried it on my home network via the internal URL and that gives me the same error.

Bei mir funktioniert es auch nicht, brauche etwas Hilfe.

Was genau muss man in der Iphone-App eintragen, speziell bei dem Token?

You’ll need to enter Authorization in the “Key” header field and Bearer xxx in the “Value” header field.

There should be a space between Bearer and your token value, but make sure there are no other extra spaces in your entries.

Should look like this:

Auto

Finally got it working… I had a ‘space’ at the end of my key (strange ‘copy’ artifact)

I managed to get this working with just Siri Shortcuts (no webhooks required), and while not optimal, figured I’d share my experience here because I think this method could be improved with added app support that could be done outside of any need for HealthKit approval.

In Shortcuts:
Shortcuts has a “Find health samples” template that queries any sample from your health data directly. So I have it grab the latest value for my weight, for example, and then send it off into Home Assistant’s existing shortcut support via the “Call Service” template, using the input_number.set_value service.

In Home Assistant:
I first needed a place for the data to go in Home Assistant, so I made an input_number helper via Configuration > Automations & Scenes > Helpers > Add Helper > Number. I’m not sure if this is the ideal service/entity to use (tried to send a state_changed event and hit some roadblocks) but at this point, the data is in Home Assistant, and I just send it into my own graph component from there.

Back to Shortcuts:
I then set up an automation to “Run Shortcut” daily after the time I usually weigh myself, and it will update directly from my phone to my instance. The downside of this is that shortcuts don’t yet support cron jobs more frequently than daily, so if you want more frequent updates, you’ll have to set up separate automations for each hour/minute you want during a day.

Shortcut Template Link: Shortcuts

Screenshot:

Pros:

  • Doesn’t require a webhook or third party app
  • Doesn’t require any Healthkit approval since the data is originating from Apple’s own Shortcuts app

Cons:

  • Shortcut automations only run as often as daily
  • The method above requires an input_number to accept the data (If you know of a better way to do this please let me know)
  • Getting more than one type of health sample (fat %, steps, etc) would require either multiple shortcuts or special parsing beyond the method shown here

Future:
What I was thinking would make this process a little nicer would be adding another option in the app’s Siri Shortcut support to update a sensor directly rather than having to call a service. One of the nice things that would come from this in addition to health data, would be the ability to turn basically anything available to shortcuts from the phone into a sensor in Home Assistant (i.e. apps that don’t have good API integrations but support shortcuts - might be a nice way to get around refresh tokens, etc)

I also presume Apple will come out with some new Shortcut features at WWDC this year that might improve this method, so keep an eye out for those :apple: :eyes:

7 Likes

THANK YOU!

I’ve been fiddeling with this for a couple of weeks without any success. This method works like a charm!

This works pretty well. Thank you for this.

Works great, thanks! Ended up porting over, autoexport is great but as you outlined is hindered by the limitations of iOS (forcing it to sync often is a bit of a pain).

thanks for that, i’m looking for the exact opposite, and in my opinion that’s not possible, right?

I would like to enrich my Apple Health data with the collected data in Home Assistant, I use the Xiaomi Miscale 2 integration and the Bodymiscale integration.

1 Like