Projects

Open Source

HC Sheets Sync

Kotlin
Jetpack Compose
Health Connect
WorkManager

A personal Android app that syncs daily Health Connect (Samsung Health) totals to Google Sheets, where an AI coaching bot reads them.

Health Connect WorkManager last 7 days Google Sheets date kcal steps workout 11.11 2140  upsert 10.11 BMR 8420  Apps Script AI coach HC Sheets Sync Kotlin + Health Connect + Google Sheets

About the project

A personal Android app built with Kotlin, Jetpack Compose and WorkManager. Once a day it reads data from Health Connect (Samsung Health) and, through Google Apps Script, writes daily totals to Google Sheets, where my AI coaching bot reads them.

Repository: github.com/kopolot/hc-sheets-sync

Key implementations

Self-healing sync

A daily background job re-sends the last 7 days and upserts them by date, so missed runs and late-logged meals catch up on their own. Workouts are upserted by session ID, so a deleted session also disappears from the sheet.

Correct aggregation

Daily sums come from Health Connect’s aggregate API, which deduplicates data across apps and splits records at midnight. Missing data stays empty instead of 0, and days where calories are only the BMR estimate get a flag.

Diagnostics and tests

An in-app screen compares aggregates with raw record sums per source app. The day logic in the app and the Apps Script receiver both have their own tests. No secrets or health data are in the repo.