苹果健康数据中心 是 AI Skill Hub 本期精选AI工具之一。综合评分 7.5 分,整体质量较高。我们推荐使用将其纳入你的 AI 工具库,帮助提升工作效率。
将iPhone/Apple Watch健康数据同步到服务器
苹果健康数据中心 是一款基于 Python 开发的开源工具,专注于 apple-health、apple-watch、docker 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
将iPhone/Apple Watch健康数据同步到服务器
苹果健康数据中心 是一款基于 Python 开发的开源工具,专注于 apple-health、apple-watch、docker 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:pip 安装(推荐)
pip install health-data-hub
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install health-data-hub
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/umutkeltek/health-data-hub
cd health-data-hub
pip install -e .
# 验证安装
python -c "import health_data_hub; print('安装成功')"
# 命令行使用
health-data-hub --help
# 基本用法
health-data-hub input_file -o output_file
# Python 代码中调用
import health_data_hub
# 示例
result = health_data_hub.process("input")
print(result)
# health-data-hub 配置文件示例(config.yml) app: name: "health-data-hub" debug: false log_level: "INFO" # 运行时指定配置文件 health-data-hub --config config.yml # 或通过环境变量配置 export HEALTH_DATA_HUB_API_KEY="your-key" export HEALTH_DATA_HUB_OUTPUT_DIR="./output"
Self-hosted Apple Health server - sync HealthKit data from your iPhone and Apple Watch into TimescaleDB, visualize it in Grafana, and get an AI-written daily briefing via a local Ollama model. Private. Local-first. Your data stays on your hardware.
New here? BRIDGE.md is the one-page tour: pipeline diagram, who it's for, what's local vs self-hosted, setup gotchas. Read that first if 500 lines of README is too much.
Keywords: apple-health · healthkit · self-hosted · quantified-self · timescaledb · grafana · fastapi · ollama · local-llm · home-assistant · docker · privacy · health-data · wearables
Your own server, on your own hardware, turning the health data your phone already collects into an AI-written daily briefing - no cloud, no subscription, no one else reading your numbers.
You point your iPhone at it. It stores everything from your Apple Watch (heart rate, HRV, SpO2, sleep, workouts, steps, and more), graphs it in Grafana, and - if you turn it on - runs a small local AI model that writes you a short narrative every morning about how your body is actually doing.
```bash cp .env.example .env
Fresh installs load db/schema.sql automatically. Existing Docker volumes keep their original schema, so the Compose stack runs the migration service before the API, worker, agents, or Home Assistant bridge start:
docker compose up -d --build
To run the same migration pass explicitly:
docker compose run --rm migrate
The runner records applied files in schema_migrations, so re-runs are safe. Migration files still live in db/migrations/ for review and manual recovery. The current set starts at db/migrations/001_audit_hardening.sql and includes later additive upgrades such as db/migrations/002_analysis_tables.sql and db/migrations/008_oauth_tokens.sql; files apply in filename order.
caddy: image: caddy:2-alpine ports: - "443:443" volumes: - ./Caddyfile:/etc/caddy/Caddyfile:ro
You need Docker installed and running, plus a terminal. On Windows, run this inside WSL2 - setup.sh is a bash script.
git clone https://github.com/umutkeltek/health-data-hub.git
cd health-data-hub
./setup.sh
That's it. setup.sh:
.env for youdocker compose up -dWhen it finishes, run ./setup.sh doctor to confirm every service is healthy. The doctor prints the exact iOS-app URL to paste into HealthSave under Settings → Server Sync.
Re-running ./setup.sh is safe - it preserves passwords and updates only the AI-related config based on your answers.
docker compose exec ollama ollama pull <new-tag> docker compose restart api ```
The tier table above is a starting point - any Ollama model tag works. Browse ollama.com/library for the full list.
./setup.sh doctor says a service isn't running.
Run docker compose logs <service> (e.g. docker compose logs api) to see why. Most first-time failures are Docker not having enough memory allocated - bump it in Docker Desktop's preferences and re-run ./setup.sh.
---
docker compose up -d ```
This starts: - TimescaleDB on port 5432 - FastAPI on port 8000 - Grafana on port 3000 (default login: admin / your GRAFANA_PASSWORD)
The database port is bound to 127.0.0.1 by default so it is available for local tooling without being exposed on your LAN.
To opt into Ollama manually, copy docker-compose.override.yml.example to docker-compose.override.yml, copy config.yaml.example to config.yaml, set analysis.daily_briefing.enabled and analysis.anomaly_detection.enabled to true, and set OLLAMA_MODEL in .env to the tag you want.
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Health check |
/api/health | GET | App-friendly health check |
/ready | GET | API plus database readiness check |
/api/apple/batch | POST | Receive metric batch from the client bridge |
/api/apple/status | GET | Return flat per-table status objects |
/api/v2/sync/runs/latest | GET | Optional latest HealthSave delivery receipt |
/api/v2/sync/coverage | GET | Optional metric-level receipt coverage |
/api/insights/latest | GET | Most recent briefing (if AI enabled) |
/api/insights/anomalies | GET | Recent anomaly findings, filterable by since and severity |
/api/insights/trends | GET | Recent HR / HRV trend findings, filterable by period=30d |
/api/insights/trigger | POST | Run an analysis pass now (if AI enabled) |
/metrics | GET | Prometheus text exposition (no auth, DB-independent) |
/api/apple/status intentionally returns top-level metric objects, not a wrapped {"status":"ok","counts":...} payload. See API.md for the compatibility contract.
There are two supported Home Assistant paths:
integrations/home-assistant/healthsave-package.yaml.The bridge publishes in two layers each cycle:
Aggregate parent device (one device, one state topic, the legacy shape):
healthsave/sensor/statehomeassistant/sensor/healthsave/<metric>/confighealthsave/statusSix entities on the parent device by default:
sensor.healthsave_heart_ratesensor.healthsave_hrv_7d_avgsensor.healthsave_steps_todaysensor.healthsave_last_sleep_hourssensor.healthsave_source_modelsensor.healthsave_room_health_statePer-source sub-devices (one device per distinct source_id seen in recent data — Apple Watch, Whoop, iPhone, etc.):
healthsave/source/<slug>/state (one JSON payload per source)homeassistant/sensor/healthsave_<slug>/<metric>/configvia_device so HA nests sub-devices under the parent.heart_rate, hrv_latest_ms, steps_today, last_sleep_hours. Only metrics with a recent non-null value get a discovery message, so HA never sees ghost entities.Example: a household running both an Apple Watch and a Whoop sees: - sensor.healthsave_apple_watch_heart_rate, _hrv_latest_ms, _steps_today, _last_sleep_hours - sensor.healthsave_whoop_heart_rate, _hrv_latest_ms, _last_sleep_hours (no _steps_today if Whoop hasn't logged any).
Source attribution comes from source_id on the ingestion tables (added to daily_activity and sleep_sessions in migration 009; native to heart_rate / hrv since v1). Rows with NULL source_id collapse to a single sensor.healthsave_unknown_* sub-device so legacy data never fragments into empty entities.
Both layers share healthsave/status so HA marks every sub-device offline together if the bridge stops.
Legacy MQTT namespace migration. Fresh installs should keep the primary HA_MQTT_STATE_TOPIC_PREFIX, HA_MQTT_DEVICE_IDENTIFIER, and HA_MQTT_DEVICE_NAME values on healthsave / HealthSave. If an existing Home Assistant install still has dashboards or automations on an older namespace, set HA_MQTT_LEGACY_STATE_TOPIC_PREFIX plus the matching legacy device identifier/name. The bridge then publishes both shapes from the same Data Hub service so Home Assistant can be migrated one entity at a time.
HA_MQTT_STATE_TOPIC_PREFIX=healthsave
HA_MQTT_DEVICE_IDENTIFIER=healthsave
HA_MQTT_DEVICE_NAME=HealthSave
HA_MQTT_LEGACY_STATE_TOPIC_PREFIX=<old-prefix>
HA_MQTT_LEGACY_DEVICE_IDENTIFIER=<old-device-id>
HA_MQTT_LEGACY_DEVICE_NAME=<old-display-name>
Enable it with Docker Compose. Two patterns:
(a) Bring your own broker. Point the bridge at an MQTT server you already run:
HA_MQTT_ENABLED=true \
HA_MQTT_BROKER=<your-mqtt-host> \
HA_MQTT_USERNAME=<optional-user> \
HA_MQTT_PASSWORD=<optional-password> \
docker compose --profile home-assistant up -d homeassistant-mqtt
(b) Use the bundled broker. Add the mosquitto profile and the stack runs an eclipse-mosquitto:2 container alongside the bridge. The bridge's default HA_MQTT_BROKER=mqtt resolves through docker DNS, and host port 1883 is published so a Home Assistant install on the same LAN can also connect by host IP. Persistence is on a docker volume so retained messages survive restarts.
HA_MQTT_ENABLED=true \
docker compose --profile mosquitto --profile home-assistant up -d
The bundled broker defaults to anonymous-on-LAN. To require auth, overlay a docker-compose.override.yml that flips allow_anonymous false and mounts a password file — the conf at deploy/mosquitto/mosquitto.conf is read-only so the override is the right seam.
Useful defaults:
homeassistanthealthsavehealthsave60 secondsDirect SQL example files remain available for setups that prefer DB polling: - integrations/home-assistant/healthsave-package.yaml - integrations/home-assistant/secrets.example.yaml
The Ollama container won't start.
docker compose logs ollama
The most common causes are: not enough free RAM (Ollama refuses to load a model that won't fit), the override file missing (re-run ./setup.sh - it copies the example), or another process holding port 11434 (stop it, or edit docker-compose.override.yml to bind a different port).
My briefing came back empty (or said "not enough data").
Two things to check:
http://localhost:8000/api/apple/status - if the table counts are all zero, sync from your phone first.I want to change the model after setup.
Edit the OLLAMA_MODEL= line in your .env, then pull the new tag and restart:
```bash
一个不错的健康数据同步工具
该工具使用 NOASSERTION 协议,商用场景请仔细阅读协议条款,必要时咨询法律意见。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
📄 NOASSERTION — 请查阅原始协议条款了解具体使用限制。
经综合评估,苹果健康数据中心 在AI工具赛道中表现稳健,质量良好。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | health-data-hub |
| 原始描述 | 开源AI工具:Self-hosted Apple Health server - sync HealthKit from iPhone/Apple Watch to Time。⭐8 · Python |
| Topics | apple-healthapple-watchdockerfastapigrafana |
| GitHub | https://github.com/umutkeltek/health-data-hub |
| License | NOASSERTION |
| 语言 | Python |
收录时间:2026-05-30 · 更新时间:2026-05-31 · License:NOASSERTION · AI Skill Hub 不对第三方内容的准确性作法律背书。