How to Configure Automatic Apple Health Exports

Create a New Automation

Important: Add the “Automations” widget for Health Auto Export in order to run automations without opening the app. (View Instructions)

  • Navigate to the Automations tab. Select New Automation.

  • Enter a name for the automation.

  • Select an Export Destination from the available options:

  • Enable the automation if you would like it to be triggered automatically.

  • Notify on Update: Apple Health data can only be accessed when your device is unlocked. Each time your device is unlocked, and the app is running in the background, Health Auto Export will attempt to update its cache. The cache update stops if your device is locked again before it completes. You will get a notification each time cached data is updated for your automation.

  • Notify When Run: Enable this notification if you want to be informed each time the app as sent data to its configured destination while the app is running in the background.

  • Sync Cadence is the minimum time between exports. This execution time is not guaranteed and is ultimately determined by the system. Select a Quantity and interval for your desired sync frequency.

    • Please note iOS does not allow apps to execute background tasks at a specified time. Heath Auto Export will make a best attempt to run in the background according to the specified sync interval but this is not a precise gurantee. Furthermore, new health data can only be acccessed during periods when your device is unlocked. Enable notifications on your automation if you need to be certain of when automations run in the background.

  • Export Format: select an option from the available options.

  • Period: Select a date range for the exported data.

    • Default: Syncs data for the full previous day plus data up to the current date and time. This sync will run multiple times daily.

    • Since Last Sync: On each sync, exports all data since the last time the export ran up until the current date and time. This sync will run multiple times daily.

    • Today: Syncs all data for the current date up to the current time. This sync will run multiple times daily.

    • Yesterday: Syncs all data for the full previous day. This sync will run only once daily.

    • Previous 7 Days: Syncs data for the full previous seven days. This sync will run only once daily.

  • Aggregation: select an aggregation interval

    • Default: When Default is set, and exporting in JSON format, Health Auto export uses the seconds interval for the Heart Rate metric and minutes for other metrics. This provides the most detailed output for Heart Rate data. When exporting to CSV, the days interval is used for all metrics.

    • minutes: Data is aggregated minute-by-minute

    • days: Data is aggregated day-by-day

    • weeks: Data is aggregated week-by-week

    • months: Data is aggregated month-by-month

    • years: Data is aggregated year-by-year

  • Select Health Metrics: Select/deselct the metrics that would be included in the export. Favorites are always included.

  • Include Health Metrics: Turn on/off whether the selected metric included in the final export.

  • Include Workouts: Turn on/off whether workouts included in the final export.

  • Save: changes to your configuration need be saved before they take effect.

    • Note: configurations are saved and encrypted in iCloud. You must be signed into iCloud and have iCloud access enabled for Health Auto Export in your iCloud settings.

  • Manual Sync: trigger a manual sync to immediately send data to your export destination

Configure Export to a REST API

  • Each automation gets an ID. This can be used to identify and correlate activity in the Activity Log with REST API requests to your server, which will be sent as a session-id in the request headers.

  • Enter a valid API URL. All requests are sent as POST requests.

  • Add request headers if necessary. The following headers are added to each request by default:

    • “Content-Type”: “application/json” for JSON format exports

    • “Content-Type”: “multipart/encoded” for CSV format exports

    • “automation-name”: “<your_automation_name>”

    • “automation-id: “<your_automation_id>”

    • “session-id”: <a session ID to identify the request>”

Configure Export to Google Drive

  • Access Token + Refresh Token

    • An access token and a refresh token are required when syncing data to Google Drive. A red X indicates that these values are currently missing and you must authorize/re-authorize Health Auto Export’s access to your Google Drive account.

    • Select “Connect Google” to begin the authorization process. When completed successfully, the access token and refresh token fields will be demarcated by green checkmarks.

  • Automation Folder Created + Folder Name

    • Since you can create multiple automations that sync to data Google Drive (e.g. weekly summary, monthly summary, etc), Health Auto Exports created a folder hierarchy that helps keep your data organized.

    • Health Auto Export (root): A Health Auto Export folder is created in the root level of your Google Drive, and acts a container for all configured automation data.

    • <Folder Name>: A subfolder is created under the root directory for each Google Drive automation. If a folder name was not provided for the automation, a default name is provided.

    • Save: you must first save the automation before this field is updated.

    • Automation Folder Created: This field is demarcated by a green checkmark when the root folder and subfolder have both been created successfully.

    • Note: Do not move the root folder or subfolder after they have been created.

Configure Export to Dropbox

  • If you have not previously performed this step, or the “Token” field is empty, you will need to select “Connect Dropbox” to begin the autorization process.

  • As this is a new integration, you may see a warning from Dropbox about “trusting the developer.” (FYI—you can trust the developer; I don’t care to steal anyone’s personal information or get sued)

  • Privacy:

    • Health Auto Export will only write data to the “Apps” folder in your Dropbox account.

    • Health Auto Export does not read the contents of your Dropbox folders.

    • By default, Dropbox provides access to data user data (username, etc) but this is not necessary and is not used.

  • Provide a Folder Name. if this folder does not already exist, it will be created at the path “Dropbox/Apps/Health Auto Export/<folder_name>”

Configure Export to Home Assistant

  • Enter your Home Assistant URL (See the Home Assistant installation and setup information if you do not know your URL)

  • The /api/states/<entity_id> endpoint is added to the base URL, and the entity name is automatically generated based on the automation name. A preview of the result URL is presented under the entered base URL.

  • Obtain an authorization token for the Home Assistant API by following the instructions outlined here.

  • Add the token to the configuration headers as the key-value pair Authorization : Bearer <your_auth_token>.

Configure Export to MQTT

  • IP Address: the IP address of the broker

  • Port: the port number in use; the default is 1883

  • Topic: set the topic to publish data to (e.g. sensor/health)

  • Client ID: set a client ID

  • Username: set if authentication is required

  • Password: set if authentication is required

Response & Errors

These fields will display successful actions and/or errors encountered when publishing data.


Activity Log

The Activity Log helps with keeping track of automation activity.

  • ID: The ID of the activity. This correlates the to the session-id on REST API requests.

  • Context: indicates whether the activity was performed as a result of a manual action, or ran automatically in the app background or foreground.

  • Result: indicates whether the activity was successful or encountered an error. For some activities, it can only be determined if data was sent, but not if an error was encountered. For example, HTTP requests in the background and MQTT messages will only be determined if they are sent by the app.

  • Timestamp: the date and time of the activity log

Automations Widget

Add the Automations widget to your Home Screen in order to run automations while Health Auto Export is in the background.

  • Follow Apple’s instructions for adding widgets to the Home Screen. In the widget menu, search for “Auto Export.”

  • Swipe to the “Automations” widget type. Tap on the widget to add it to your Home Screen.

  • While the widget is still in edit mode (jiggling), tap on the widget to select one of the automations already defined inside the app. By default, the first automation is selected when adding the widget.

  • If you have multiple automations defined, add a widget corresponding to each automation you would like to run automatically.

Troubleshooting

Troubleshoot data syncing issues by reviewing the documentation here.