You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bump version to v1.3.4 - a missing 32-bit pair partner no longer decodes as zero (#367)
Reported by tdalejandro: pv1_power published as 65,536,000 W and pv2_power as 109,544,683 W, with the same values recurring byte-for-byte 14 hours apart. The repetition identified the cause.
Decoded as 32-bit pairs, two of the three impossible values had a low word of exactly zero. _get_register_value() substituted 0 for a pair register missing from the read cache, so a truncated block capturing the high word but not the low word decoded as (high << 16) - a high word of 10000 becoming 65,536,000 W. Those values went into HA long-term statistics as real measurements.
The protocol is unambiguous: UINT32/INT32 are defined as high word first, low word last, and every 32-bit register table entry declares a length of 2. A 32-bit value always occupies both registers, so a missing partner cannot mean zero - it means the read did not complete. The decoder now returns None.
Protocol-level rather than profile-specific, so it applies to every 32-bit register in every profile. The only behaviour change is that a value which was previously garbage now reads as no value; a complete pair whose high word is genuinely 0 still decodes normally, which is covered by test.
Three regression tests added. 191 pass, including every pre-existing decode test.
NOT fixed: five call sites in the WIT battery-power path use the same substitution, but there pair_addr may legitimately be None - the profile genuinely having no high word - which is a different case from a register that exists but was not read. Separating those safely needs a WIT owner to verify given that path's history in #247 and #323.
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments