Skip to content

feat(pixii): report the Pixii's own charge ceiling (2.2.0) - #281

Open
frahlg wants to merge 2 commits into
mainfrom
pixii-ceiling
Open

frahlg wants to merge 2 commits into
mainfrom
pixii-ceiling

Conversation

@frahlg

@frahlg frahlg commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Refs #175

A Pixii Home 20 kWh shows 90 % in FTW and 100 % in the Pixii app, and does not take charge orders at 90 %. FTW kept planning "90 → 95 %, 1.0 kWh" and ordering charge the battery never took.

What Pixii's own Modbus mapping says (U8022_06ENG rev 2.20, the same document #228 cites):

  • 40132 SoC is "State of charge in %", scaled by SoC_SF (40177). Nothing in the document puts it on another scale.
  • 40128 SoCMax, 40129 SoCMin, 40130 SoCRsvMax ("maximum reserved state of charge") and 40131 SoCRsvMin are all marked in use and all use SoC_SF: the same scale as the SoC.
  • 39932, remaining charging energy, is SoH × (Max Reserved SoC − SoC) × nominal energy. Pixii's own count of what can still be charged ends at the reserved maximum.
  • 39915–39917 are the gross SoC and its minimum and maximum safety limits, in tenths of a percent. The document does not say how gross relates to the SoC at 40132.
  • It does not say how the Pixii app turns the SoC into its 100 %.

So the evidence points to a configured charge ceiling on the SoC's own scale, not a different SoC scale. This PR reports that ceiling and does not remap the SoC.

Change (pixii 2.2.0).

  • Each poll the driver reads 40128–40131 and 39915–39917, two reads.
  • It reports the lower of SoCMax and SoCRsvMax as max_soc_fract on the battery. Only these two share the SoC's scale. A value below 50 %, above 100 % or 0xffff, or a failed read, gives no ceiling and the key is left out. Real ceilings sit around 80–100 %; Core applies the same 50 % bound.
  • The gross SoC and safety limits (39915–39917) go to history only, never into the ceiling.
  • Every value goes to history (battery_soc_max_pct, battery_soc_reserve_max_pct, battery_soc_min_pct, battery_soc_reserve_min_pct, battery_soc_gross_pct, battery_soc_safety_min_pct, battery_soc_safety_max_pct). The driver logs the ceiling and the register it came from when it changes.
  • read_sf now treats 0x8000, SunSpec's unimplemented scale factor, as no scaling. Read as −32768 it scaled the SoC and every limit to zero.

max_soc_fract is the @srcful/data-models name for a battery's own maximum SoC (battery metadata there; FTW has no metadata channel, so it rides on the reading). docs/WRITING-A-DRIVER.md gains a short section, and test_emit_fields.py allows the key.

Paired Core PR: srcfl/ftw#2083. It plans and dispatches to the lower of the configured ceiling and this one, holds it across a missed read for up to 10 minutes, and ignores one below 50 % or at or below the SoC floor. An older Core ignores the key.

Driver evidence

Field check still needed

On the #175 site, with driver 2.2.0:

  1. Which of 40128 (battery_soc_max_pct) and 40130 (battery_soc_reserve_max_pct) reads 90, and the log line Pixii: charge ceiling … from …. If neither does, the ceiling is elsewhere and this PR does not fix the site.
  2. The lower limits (battery_soc_reserve_min_pct, battery_soc_min_pct), the gross values (39915–39917) and the app's figure at a second charge level. That shows how the app maps to 100 %. Nothing here depends on it, and no remap should be added without it.
  3. With the paired Core: the plan stays at or below 90 %, the battery shows full, no charge order goes out at 90 %, and the measured battery power agrees.

Relation to #228

#228 (calibration via StVnd 116, pixii 2.1.10) has right of way on pixii.lua. This branch is cut from main and keeps clear of #228's lines: the new code sits after emit_troubleshooting_metrics, plus two lines in driver_poll and one in read_sf. A git merge-tree against #228's head conflicts in pixii.lua only on the version line, plus the generated catalog files (index.yaml, devices.yaml, support status, CHANGELOG.md, manifest).

Whichever PR merges second takes the next version number above the first (2.2.0 here, 2.1.10 in #228) and regenerates the catalog files. Both add the same Pixii PDF to upstream_docs; keep one entry.

Safety

  • A driver that can command its device has control on. Unchanged; this change only reads.
  • Vendor signs are converted at the driver boundary. No power values change.
  • Cached telemetry becomes stale instead of being re-emitted as fresh. A failed read leaves the ceiling and its metrics out.
  • No credentials, serial numbers, private addresses or site data are included.

Control evidence

Not applicable: no control path changes.

Checks

  • Commits include Signed-off-by.
  • make test-driver ID=pixii: 139 passed, 13 skipped.
  • make check: 5443 passed, 928 skipped.

New tests in drivers/tests/test_pixii_charge_ceiling.py, ten cases:

  • the reserved maximum as ceiling, with the SoC not remapped;
  • the lower of the two limits wins;
  • gross safety limits go to history only;
  • the scale factor applies, and an unimplemented one (0x8000) no longer zeroes the SoC;
  • zero, unsupported, impossible and below-50 % limits give no ceiling;
  • failed reads leave the ceiling out.

Six fail against main; the four invalid-value cases pass there by design.

🤖 Generated with Claude Code

A Pixii can stop charging below 100 %. On one site its SoC held at 90 while
Core kept planning and ordering charge to 95 %, and the Pixii app showed
100 % (#175).

Pixii's Modbus mapping (U8022_06ENG rev 2.20) gives the SoC register as a
percentage and names the upper limits on the same scale: SoCMax (40128),
SoCRsvMax (40130) and the maximum SoC safety limit (39917, per mille, where
"regulation will stop"). The driver reports the lowest valid one as
max_soc_fract, the `@srcful/data-models` name for a battery's own maximum SoC.
The SoC stays as read: the document does not say how the Pixii app maps it
to 100 %. Every limit, the lower ones and the gross SoC go to history so a
field check can show which one holds.

Refs #175

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T07:40:20.294621Z f367b62 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Review findings:

- 39917 is a gross safety limit in tenths of a percent, and Pixii does not
  document how gross relates to the SoC at 40132. max_soc_fract now comes
  only from SoCMax (40128) and SoCRsvMax (40130), which share the SoC's
  scale factor. 39915-39917 stay in history.
- A limit below 50 % is taken as a misread and left out. Real ceilings sit
  around 80-100 %, and Core applies the same bound.
- read_sf treats 0x8000, SunSpec's unimplemented scale factor, as no
  scaling. Read as -32768 it scaled the SoC and every limit to zero.

Refs #175

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>

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.

1 participant