From b1ed8cdb20ba95418d160d82a331ade9900ccf5b Mon Sep 17 00:00:00 2001 From: Joshua King Date: Fri, 5 Jun 2026 20:22:06 -0400 Subject: [PATCH] hub: emit battery_pct/video_remaining as null, not omitted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SPA types these as number|null and null-checks them, but omitempty dropped the field entirely when uncalibrated → undefined in JS → "NaN%". Always serialize the field (null when unknown) so the card shows "N/A". Co-Authored-By: Claude Opus 4.8 --- pkg/models/camera.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/models/camera.go b/pkg/models/camera.go index bdcc40e..13fdd31 100644 --- a/pkg/models/camera.go +++ b/pkg/models/camera.go @@ -33,8 +33,11 @@ type StatusLog struct { type CameraStatus struct { CameraID string `json:"camera_id"` FriendlyName string `json:"friendly_name"` - BatteryPct *int `json:"battery_pct,omitempty"` - VideoRemainingSec *int `json:"video_remaining_sec,omitempty"` + // Not omitempty: the SPA expects these as `number | null`. Omitting them + // makes the field `undefined` in JS, which slips past null checks and + // renders as "NaN%". + BatteryPct *int `json:"battery_pct"` + VideoRemainingSec *int `json:"video_remaining_sec"` Recording bool `json:"recording"` Mode string `json:"mode"` Resolution string `json:"resolution"`