Skip to content

fix(pixii): detect active battery calibration via Modbus - #228

Open
segran2 wants to merge 9 commits into
srcfl:mainfrom
segran2:fix/pixii-calibration-service
Open

segran2 wants to merge 9 commits into
srcfl:mainfrom
segran2:fix/pixii-calibration-service

Conversation

@segran2

@segran2 segran2 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

On a Pixii undergoing scheduled SoC calibration, a read of SunSpec 802 register 40137 (ChaSt) returned 0xffff while Pixii register 40108 (StVnd) returned 116, the documented battery calibration service. FTW kept requesting idle and the battery continued charging under its local calibration.

Recognize either calibration signal and keep battery and meter telemetry live. Use the Core calibration state when the host provides it. Older hosts continue to suspend control through the existing fault gate.

On the affected Pixii, the local driver derived from this change reported service 116 and stopped dispatching power commands once calibration was detected. The Pi journal shows no Pixii power setpoints between calibration detection at 01:24:41 and the status transition at 03:00:11 CET on 15 November 2026. The same FTW process resumed dispatch automatically and issued a 463 W Modbus charge setpoint at 03:00:12, then 0 W at 03:00:17. A later live read confirmed calibration was cleared and battery telemetry remained fresh.

Remaining hardware validation

The earlier run used a local driver derived from this change. A full scheduled calibration on the exact packaged Pixii 2.1.10 build remains pending. On 22 November, the field box was running 2.1.8, and 2.1.9 was the newest version available in its signed driver catalog. The final hardware run can take place once 2.1.10 is available for installation on that box.

During the run, capture StVnd and ChaSt to verify that StVnd = 116 is sufficient when ChaSt is unavailable. Confirm that FTW suspends battery dispatch while telemetry stays fresh, then clears the calibration state and makes the battery eligible for dispatch when calibration finishes. The automated tests already cover both host.set_calibrating and the legacy fault gate.

Companion Core change: srcfl/ftw#2017.

Signed-off-by: Segran <goran@andersson-stehag.se>
Signed-off-by: Segran <goran@andersson-stehag.se>
Signed-off-by: Segran <goran@andersson-stehag.se>
@segran2
segran2 force-pushed the fix/pixii-calibration-service branch from ef41395 to a5ded98 Compare November 15, 2026 00:41

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pixii 2.1.10: reads StVnd (40108) and treats code 116 as calibration, so dispatch is suspended when SunSpec ChaSt is unsupported. Version, index, manifest and sha256 are bumped consistently, and the new test covers 116, 0xffff (keeps the last verdict) and 119 (clears).

  • Needs a human decision: this adds host.set_calibrating to spec/host-api-profile.json. Older Core falls back to set_device_fault, which is fine. But is the Core side that implements set_calibrating merged or planned? If not, the new API is spec-only for now.
  • Nit: the 101-129 range for service_known is from the Pixii mapping (table 23). A one-line link in the comment would help whoever extends it.
  • No secrets, no new hosts or dependencies.

Logic looks right to me. Safe to merge from my read once the Core question is answered.

segran2 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, Mira. I haven’t confirmed whether host.set_calibrating is already merged in Core or tracked in a follow-up. Until Core exposes it, the driver will use the set_device_fault fallback. I’ll confirm the Core status before merging and add a reference to Table 23 next to the service_known range.

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treats Pixii StVnd (40108) == 116 as battery calibration as well as ChaSt == 7, so dispatch still pauses when the SunSpec status reads 0xffff. Uses host.set_calibrating when the host has it and falls back to the device-fault gate on older cores.

Read the whole diff, found nothing blocking.

  • Security: nothing. No new hosts, deps or secrets.
  • Logic: the verdict only updates when ChaSt is recognised or StVnd is in 101–129, and holds the last verdict otherwise. That matches the test (0xffff keeps calibrating, 119 clears it).
  • Low, host support: set_calibrating is a new entry in host-api-profile.json. The fallback covers older hosts, but it's worth confirming ftw-core actually implements it. Otherwise the "legacy fault" path stays the only live one.
  • Low, test gap: the fallback branch (set_calibrating == nil with service 116) and ChaSt == 7 through the new code path aren't covered by the new test. Both look right on read.

Safe to merge from my read.

@frahlg

frahlg commented Nov 21, 2026

Copy link
Copy Markdown
Member

host.set_calibrating is not on Core master; it is in srcfl/ftw#2017, which is open. Without it the driver falls back to set_device_fault. Please add the Table 23 link next to the service_known range, as you said. We will review #2017 first, so the driver and Core agree.

Signed-off-by: Segran <goran@andersson-stehag.se>
Signed-off-by: Segran <goran@andersson-stehag.se>

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What it does: pixii now reads StVnd (reg 40108) and treats service 116 as battery calibration, so dispatch is suspended even when SunSpec ChaSt is unsupported. It reports through a new host.set_calibrating, falling back to set_device_fault on older Core.

  • question: host.set_calibrating is a new host API entry (added to spec/host-api-profile.json). Is it already implemented in Core, or does this ride on the fallback until it lands? Either way the driver behaves correctly, I just want to be sure nobody expects the new path yet.
  • note: a recognised StVnd value in 101-129 clears calibration even when ChaSt is unknown. That matches the stated intent (StVnd is the better signal), and the test covers 0xffff keeping the last verdict.
  • security screen: no secrets, no new dependencies, no new network destinations. The only new URL is a doc link in the manifest.

Safe to merge from my read, pending the answer on set_calibrating. CI is green on 6b45928.

Signed-off-by: Segran <goran@andersson-stehag.se>
Signed-off-by: Segran <goran@andersson-stehag.se>
@segran2
segran2 force-pushed the fix/pixii-calibration-service branch from 419e4e5 to e852a90 Compare November 22, 2026 21:10

segran2 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@miravoss26, following up on your host.set_calibrating question. The Core implementation is in srcfl/ftw#2017, which is still open. The Pixii driver calls host.set_calibrating when the host exposes it. On hosts without it, set_device_fault suspends dispatch during calibration and clears the fault when calibration ends.

The test suite now covers both gaps you identified. StVnd = 116 exercises the legacy fault gate when host.set_calibrating is absent, and ChaSt = 7 exercises the dedicated calibration callback. CI passed. The final hardware run with the exact packaged 2.1.10 build is pending availability in the box’s signed driver catalog.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants