Repository navigation
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>
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.