Install
openclaw skills install apple-watchApple Watch health data sync via Health Auto Export app. Use when querying sleep, heart rate, steps, workouts, or any health metrics. Also use when setting u...
openclaw skills install apple-watchThis skill has TWO parts: PC setup (automated) and Phone setup (requires user action). Do NOT just run setup.py and say "done". You MUST walk the user through the full flow.
Ask the user to confirm ALL of these before proceeding:
If any is missing, help them resolve it first. Do NOT run setup.py until all are confirmed.
Run python scripts/setup.py - generates server, dashboard, API key, and phone templates.
setup.py does NOT start the server. You must start it yourself in step 2.
The server MUST run independently of any agent session. Do NOT start it in an exec session that will get killed by heartbeat or session recycling.
Windows - register as a startup task:
$action = New-ScheduledTaskAction -Execute "pythonw.exe" -Argument "server.py" -WorkingDirectory "<health-sync-dir>"
$trigger = New-ScheduledTaskTrigger -AtLogon
Register-ScheduledTask -TaskName "HealthSyncServer" -Action $action -Trigger $trigger -RunLevel Highest -Force
Start-ScheduledTask -TaskName "HealthSyncServer"
macOS - use launchd plist:
cat > ~/Library/LaunchAgents/com.health-sync.server.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>com.health-sync.server</string>
<key>ProgramArguments</key><array>
<string>python3</string><string>server.py</string>
</array>
<key>WorkingDirectory</key><string>HEALTH_SYNC_DIR</string>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>StandardOutPath</key><string>HEALTH_SYNC_DIR/server.log</string>
<key>StandardErrorPath</key><string>HEALTH_SYNC_DIR/server.log</string>
</dict>
</plist>
EOF
# replace HEALTH_SYNC_DIR with actual path, then:
launchctl load ~/Library/LaunchAgents/com.health-sync.server.plist
Quick start (if you just need it running now, not persistent):
# Windows
start /B pythonw.exe server.py
# macOS / Linux
nohup python3 server.py > server.log 2>&1 &
Before starting, kill anything already on port 3001:
# Windows
(Get-NetTCPConnection -LocalPort 3001 -State Listen -ErrorAction SilentlyContinue).OwningProcess | ForEach-Object { Stop-Process -Id $_ -Force }
# macOS / Linux
lsof -ti:3001 | xargs kill -9 2>/dev/null
Verify it's running:
curl.exe -s -H "api-key: <key>" http://localhost:3001/api/summary
Note: on Windows use curl.exe (not curl which is a PowerShell alias for Invoke-WebRequest).
After server is running, walk the user through phone configuration. Read the API key from .env.json first - you will need to tell the user. SEND THE FILE TO USER.
templates/ to the user's iPhone. If your IM channel supports file attachments, send the file directly. Otherwise, paste the key settings as text.tutorial_imgs/step1.png with your message TO USER
tutorial_imgs/step2.png.with your message TO USER
api-keytutorial_imgs/step3.pngwith your message TO USERFallback: if the user is confused by the template import flow, fall back to fully manual setup (Automations -> + -> REST API -> enter URL and header by hand). Only use this fallback when necessary.
If server.py and .env.json already exist:
When the user asks about their health (sleep, heart rate, steps, etc.):
curl.exe (NOT curl on Windows):curl.exe -s -H "api-key: <KEY>" "http://localhost:3001/api/latest/metrics/sleep_analysis?n=3"
curl.exe -s -H "api-key: <KEY>" "http://localhost:3001/api/latest/metrics/heart_rate?n=5"
curl.exe -s -H "api-key: <KEY>" http://localhost:3001/api/summary
When the user wants to see their health stats visually, or you want to proactively show a summary:
You can use your native heartbeat capability to periodically check the user's health data (e.g. detect wake-up, monitor heart rate). Add health check tasks to HEARTBEAT.md.
Example HEARTBEAT.md entry:
## Health Check
- Query: curl.exe -s -H "api-key: <KEY>" "http://localhost:3001/api/latest/metrics/sleep_analysis?n=1"
- Query: curl.exe -s -H "api-key: <KEY>" "http://localhost:3001/api/latest/metrics/heart_rate?n=1"
- If sleep ended within last 2 hours: send wake-up greeting with sleep duration
- If no data or server not responding: reply HEARTBEAT_OK (do NOT try to restart server)
IMPORTANT for heartbeat:
curl.exe not curl on Windows (avoid PowerShell alias issues).Sync Apple Watch health data to your PC in real time.
Hardware:
Software (phone side):
Software (PC side):
Apple Watch -> iPhone HealthKit -> Health Auto Export app -> HTTP POST -> Python server -> JSONL files
Your iPhone periodically sends health data as JSON to a lightweight Python server running on your PC. The server stores everything as append-only JSONL files, queryable via REST API.
python scripts/setup.py
No git account needed. No Docker needed. Flask is auto-installed if missing.
Setup will:
templates/ to your iPhone (AirDrop, email, etc.)api-key.env.json (setup.py prints this)The server must stay running to receive data from your phone.
Windows - scheduled task (survives reboot):
$action = New-ScheduledTaskAction -Execute "pythonw.exe" -Argument "server.py" -WorkingDirectory "<health-sync-dir>"
$trigger = New-ScheduledTaskTrigger -AtLogon
Register-ScheduledTask -TaskName "HealthSyncServer" -Action $action -Trigger $trigger -RunLevel Highest -Force
macOS - launchd (survives reboot):
# create plist at ~/Library/LaunchAgents/com.health-sync.server.plist
# see Agent Instructions section for full plist template
launchctl load ~/Library/LaunchAgents/com.health-sync.server.plist
Quick (non-persistent):
# Windows
start /B pythonw.exe server.py
# macOS / Linux
nohup python3 server.py > server.log 2>&1 &
health-sync/
SKILL.md <- this file
scripts/setup.py <- one click setup
server.py <- receiver server (generated)
dashboard.html <- web dashboard (generated)
.env.json <- API key (auto-generated, gitignored)
.gitignore <- ignores .env.json, data/, upstream/
data/ <- received health data
metrics/ <- heart_rate.jsonl, sleep_analysis.jsonl, ...
workouts/ <- workouts.jsonl
templates/ <- phone automation config JSONs (importable)
upstream/ <- original repo (Grafana dashboards, Docker setup)
python server.py
API key is in .env.json (generated by setup.py). Use curl.exe on Windows:
# get your api key
python -c "import json; print(json.load(open('.env.json'))['api_key'])"
# summary of all data
curl.exe -s -H "api-key: YOUR_KEY" http://localhost:3001/api/summary
# latest N records
curl.exe -s -H "api-key: YOUR_KEY" "http://localhost:3001/api/latest/metrics/sleep_analysis?n=5"
curl.exe -s -H "api-key: YOUR_KEY" "http://localhost:3001/api/latest/metrics/heart_rate?n=10"
curl.exe -s -H "api-key: YOUR_KEY" "http://localhost:3001/api/latest/metrics/step_count?n=10"