Repository navigation
fix(battery): explain calibration and suspend manual control - #2017
Conversation
…on-status Conflicts: go/internal/api/api_control_feedback_test.go
miravoss26
left a comment
There was a problem hiding this comment.
Adds a device-managed calibration state: new set_calibrating host call, DriverHealth.Calibrating, dispatch/planning suspended for that battery, scoped manual hold rejected with 409 (and the UI disables Install hold). Tests cover the API rejection and the feedback state. Security screen: nothing found (no new deps, hosts, secrets or authz changes).
IsOnline()now returns false while calibrating. Fine for dispatch, but every other consumer ofIsOnline(health endpoint, driver inventory, support report, any offline alerting) will now read a calibrating battery as offline. The new test asserts this on purpose; worth a quick grep that nothing pages on it.- The flag has no timeout. If a driver sets
set_calibrating(true)and then stops calling (crash, bad poll), control stays suspended until stale-status logic marks it offline anyway. Probably acceptable, but say so if intended. battery_calibratingis added tocontrolVerificationLost's exclusion list, good: no false 'lost control' during calibration.
Safe to merge from my read, with the first point as a check rather than a blocker.
|
A battery under calibration is unavailable for control. The device manages its own charge and discharge during calibration, and FTW setpoints or manual holds could interrupt that process. The battery can still report telemetry, but planning and dispatch must exclude it from controllable capacity until the device reports that calibration is complete. |
|
Thanks for the note on why a calibrating battery is left alone. Two review points still need an answer. First, |
Driver inventory and status, support reports, app-link snapshots and Home Assistant availability read IsOnline. Non-battery health gates also use it for site-meter, EV, V2X, PV and vehicle telemetry. Use CanControl for battery dispatch, planner eligibility, scoped holds, self-tune and EV battery boost. Reject queued battery commands that reach the driver after calibration started. Calibration has no independent expiry. The telemetry watchdog still marks a silent battery offline. Fresh telemetry restores online status and explicit completion from the driver restores control eligibility.
miravoss26
left a comment
There was a problem hiding this comment.
Adds a device-managed "calibrating" state for batteries (Pixii). Calibrating batteries keep live telemetry but are dropped from dispatch, planning and scoped manual holds, and the UI shows "Calibrating" instead of a fault. A new host.set_calibrating Lua call and CanControl() (online and not calibrating) carry this through.
Findings
- Medium, go/internal/telemetry/store.go (
SetDriverCalibrating): calibration only ends when the driver reports it. If a Lua driver restarts or crashes mid-calibration and doesn't callset_calibrating(false)on init, the battery stays uncontrolled indefinitely (your test confirms recovery of telemetry deliberately doesn't re-enable control). Does the registry resetCalibratingon driver stop/reload? I didn't see it in the diff. Worth a reset on driver (re)start or a test for it. - Low, api_battery_manual.go (
handleBatteryManualHoldGet):CalibratingDriversis built by ranging over a map, so the order varies between calls. Sort it. Also checkAllHealth()entries are safe to read without the store lock, sinceIsOnline()readsStatus. - Low, scope: the
energy-history-integration.test.mjschange is a separate CI-flake fix (fixed clock). Fine, but it would read better as its own commit. - Security screen: no secrets, no new deps or hosts.
set_calibratingis scoped to the calling driver's own name, so a driver can only suspend control of itself.
The IsOnline() to CanControl() swaps look complete across control, mpc and loadpoint paths, and the new tests cover dispatch, API and feedback. Safe to merge from my read once the restart-reset question is answered.
Signed-off-by: Segran <goran@andersson-stehag.se>
Signed-off-by: Segran <goran@andersson-stehag.se>
miravoss26
left a comment
There was a problem hiding this comment.
Adds a Calibrating health state: telemetry stays live, CanControl() replaces IsOnline() at the dispatch, planner and manual-hold decision points, the UI shows it as informational, and the scoped hold API returns 409 for a calibrating battery. It depends on srcfl/device-drivers#228 for the driver side.
- Design reads right. Keeping calibration separate from
DeviceFaultavoids the false "blocked" signal, and keepingIsOnline()for diagnostics whileCanControl()gates control is a clean split. The tests cover the watchdog and recovery path and the restart carry-over. - Worth a thought (low): calibration can only be cleared by the driver reporting it. The state is carried across a
Reload/Restart(RemoveForReplacement), so if the replacement driver never callsset_calibrating(for example a catalog downgrade to pixii 2.1.9 mid-calibration), the battery stays control-suspended until the driver is removed. It fails safe and is visible in the UI, but a note in the docs or a max-age on the carried state would make it less surprising. - Same shape for a device that reports 116 indefinitely: no timeout, which I think is the right default, but it means a stuck unit needs a human to notice.
- Not verified from the diff: I read the changed
IsOnline()call sites, and I haven't grepped the rest of the tree for any remaining battery-control path that still usesIsOnline(). - Security screen: no secrets, no new dependencies, no new network destinations. The new endpoint field is read-only status; the 409 is a tightening.
Safe to merge from my read, once #228 lands and the 2.1.10 hardware run passes.
Signed-off-by: Segran <goran@andersson-stehag.se>
Moves the driver pin from srcfl/device-drivers b07a409b to 8aeecee3. Only tibber and pixii change: - tibber 1.1.3 (srcfl/device-drivers#282) declares ws_hosts = { "websocket-api.tibber.com" }, so a box set up from the UI opens the live stream (#1822). - pixii 2.1.10 (srcfl/device-drivers#228) reports calibration with host.set_calibrating (#2017). - pixii 2.2.0 (srcfl/device-drivers#281) reports max_soc_fract (#2083). Two Core tests ran the bundled Pixii and expected calibration as a device fault, as pixii 2.1.9 reported it. They now expect Calibrating set, control off, no fault and the driver still online, which is what 2.1.10 reports on a Core with host.set_calibrating. Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
When Pixii calibrates its batteries, it can continue to charge while the FTW setpoint remains at 0 W. This is normal device-managed operation. Show Calibrating under Are we in control?, keep measurements live, and suspend power dispatch and planning for the calibrating battery.
Disable Install hold for that battery and explain why. Reject the same scoped request at the API. An all-batteries override can still apply to other eligible batteries.
The Pixii driver change is in srcfl/device-drivers#228. The bundled driver pin can follow once that change lands.
Validation
make verifypassed locally. GitHub's web, Go, race and full-stack jobs passed on the updated PR head.Driver restart during calibration
Commit
1177097keeps the calibration guard across driver replacement until the replacement driver reports that calibration has ended.