From fb5851c1aec84a5b11cc7dace149322f9826182e Mon Sep 17 00:00:00 2001 From: Anthony Merlo Date: Sat, 22 Aug 2026 23:29:16 +0100 Subject: [PATCH] v11: use HealthUnit.fromString('kg') instead of HealthUnitPrefix --- scripts/health-sync.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/health-sync.tsx b/scripts/health-sync.tsx index fb89d72..cc7c068 100644 --- a/scripts/health-sync.tsx +++ b/scripts/health-sync.tsx @@ -1,5 +1,5 @@ // @ts-nocheck -// Health Sync v10 — full version: read HealthKit + POST to /ingest +// Health Sync v11 — full version: read HealthKit + POST to /ingest import { Script, Notification } from "scripting" @@ -9,11 +9,11 @@ async function main() { const SERVER_URL = "http://chronos:9432/ingest" const API_KEY = "333f09ce904e9cbbe3b578fda393be92869122c7222dbccd" - console.log("v10: script started") + console.log("v11: script started") // --- Units --- const U = { - kg: HealthUnit.gramUnit(HealthUnitPrefix.kilo), + kg: HealthUnit.fromString("kg"), mmHg: HealthUnit.millimeterOfMercury(), bpm: HealthUnit.count().divided(HealthUnit.minute()), count: HealthUnit.count(), @@ -72,7 +72,7 @@ async function main() { } // --- Read health metrics --- - console.log("v10: reading health metrics...") + console.log("v11: reading health metrics...") const weight = await readLatest("bodyMass", U.kg) const bpSys = await readLatest("bloodPressureSystolic", U.mmHg) @@ -82,7 +82,7 @@ async function main() { const steps = await readTodaySum("stepCount", U.count) const spo2 = await readLatest("oxygenSaturation", U.percent) - console.log(`v10: weight=${weight?.value} bpSys=${bpSys?.value} bpDia=${bpDia?.value} hr=${hr?.value} rhr=${restingHr?.value} steps=${steps} spo2=${spo2?.value}`) + console.log(`v11: weight=${weight?.value} bpSys=${bpSys?.value} bpDia=${bpDia?.value} hr=${hr?.value} rhr=${restingHr?.value} steps=${steps} spo2=${spo2?.value}`) // --- Build samples --- const samples = [] @@ -143,7 +143,7 @@ async function main() { }) } - console.log(`v10: ${samples.length} samples to send`) + console.log(`v11: ${samples.length} samples to send`) // --- POST to server --- if (samples.length === 0) { @@ -161,18 +161,18 @@ async function main() { timeout: 10 }) const res = await response.json() - console.log(`v10: server response = ${JSON.stringify(res)}`) + console.log(`v11: server response = ${JSON.stringify(res)}`) await notify(`Sent ${res.ingested || samples.length} samples`) } catch (e) { - console.log(`v10: POST error = ${e}`) + console.log(`v11: POST error = ${e}`) await notify(`Error: ${e.message || e}`) } } - console.log("v10: done") + console.log("v11: done") } main().then(() => Script.exit()).catch((e) => { - console.log("v10: main() error = " + e) + console.log("v11: main() error = " + e) Script.exit() }) \ No newline at end of file