X1 Hybrid Gen4: fix battery current sign, add Load power and Run Mode - #216
Conversation
Battery current (register 15) is a signed value. Decoding it with div100 alone reports a large positive number (~652 A) whenever the battery is discharging; twoway_div100 gives the correct signed reading. Verified on a type 15 inverter (ver 3.019.01) against battery power / battery voltage. Also expose two registers this class was not decoding: - Load power (register 38, to_signed) - Inverter Run Mode (register 10), raw enum matching the X3 Hybrid G4 run-mode table; reads 2 (Normal) across both existing X1 Hybrid Gen4 fixtures and the new one. Adds a ReadRealTimeData fixture from a discharging type 15 inverter (the case the sign bug affected) and updates the two existing X1 Hybrid Gen4 expected-value dicts for the new sensors.
1b6d920 to
6016ffc
Compare
|
Heads up on CI: the |
f5584b1 to
6016ffc
Compare
|
Updated: reverted the black-reformat commit, this PR is now just the X1 Hybrid Gen4 change. The CI failures on this branch are pre-existing, not from this PR. The workflow does
My additions pass |
What
For the
X1HybridGen4inverter (APItype: 15):div100alone. On a discharging battery that produces a large positive number (I saw ~652 A).twoway_div100gives the correct signed value.Load power(register 38,to_signed).Inverter Run Mode(register 10, raw enum, same table asX3HybridG4).Why
My inverter (
type: 15,ver: 3.019.01) reports battery current as65316while discharging ~250 W at ~115 V.div100→653.16 A.twoway_div100→to_signed(65316)/100→-2.2 A, which matchesbattery power / battery voltage(-252 W / 114.9 V).The two extra registers are useful and already validated by the fixtures.
Tests
X1_HYBRID_GEN4_V_3_019_RESPONSE/_VALUES: a realReadRealTimeDatacapture from a dischargingtype: 15inverter (the case the sign bug affected). Serial fields sanitised.X1HybridGen4expected-value dicts (X1_HYBRID_G4_VALUES,X1_HYBRID_G4_V_3_018_VALUES) withLoad powerandInverter Run Mode.Battery currentis unchanged for both (their raw values are small positives, sotwoway_div100==div100there).pytest: 191 passed, 135 skipped.flake8clean.Note
Inverter Run Modereads2("Normal") across all three fixtures; a maintainer with anothertype: 15unit confirming register 10 would be welcome. A decoded text variant (likeX3HybridG4's "Run mode text") could be added later.