v1.0.2
Fix: Grid Import Energy / Net Grid Energy wrong on MOD-XH and SPH (#336 follow-up)
Two related bugs, both specific to XH hybrid and SPH profiles.
Bug 1 — Grid Import Energy Today/Total reverts to formula when register reads 0
The hardware-path gate had an energy_to_user_today > 0 condition. When the hardware register legitimately reads 0 (no grid import yet that morning), this condition evaluated False and the code fell through to the broken formula: load + export − energy_today.
On MOD-XH and other XH hybrids, energy_today is MPPT DC yield — not AC output — so the formula produces a non-zero result that rises with morning load and then declines as PV output overtakes consumption. This is the characteristic curve reported in the issue.
Fix: removed the > 0 guard. Zero is a valid hardware reading for SPH/XH profiles meaning no grid import has occurred yet today.
Bug 2 — Grid Energy Today/Total (net) shows wrong value
The net grid sensors were independently re-calculating import using the same broken formula rather than reading energy_to_user_today/total directly. Even after the import sensor was correct (740.3 kWh from hardware), the net sensor was computing 327.5 − 1058.5 = −731 kWh instead of the correct 327.5 − 740.3 = −412.8 kWh.
Fix: for SPH and XH hybrid profiles, the net sensors now source their import component from the hardware register. Non-hybrid models (MIN, MIC, etc.) continue to use the formula, which is architecturally correct for those inverters.