4.8 KiB
2026-04-26 — inverter MQTT entity cleanup
Mirrors the eg4battery cleanup landed earlier today. Same set of issues
(no precision hints, missing state_class, dead/misleading entities)
plus a couple of powermon-specific quirks.
What changed
-
New patch (g) —
outputformats/hass.py. Rewrites powermon's HA discovery-payload assembly so:suggested_display_precisionis set per unit (V/A → 1 dp, W/VA/% → 0, °C → 0, Hz → 1, Ah → 1, etc.). Frontend now renders52.5 Vinstead of52 V.state_class: measurementis set by default for numeric sensors that don't have an explicit class. Required for HA's long-term statistics + Energy dashboard wiring; previously onlyac_output_active_powerhad it.last_reset: <datetime>removed from every payload. HA spec allows it only onstate_class: totalcumulative counters; onmeasurementsensors HA warns and ignores. Upstream emits it unconditionally.force_update: "true"removed from default. Forced HA to record every state publish even when value unchanged; bloats DB for slow-changing fields (battery V, currents, temps).
-
Patch (a) tweak.
"DC-AC power direction"→"DC AC power direction". Causes the HA entity_id to becomedc_ac_power_direction(underscore, conforming) rather than the previousdc-ac_power_direction(hyphen, non-conforming). -
excl_filteradded to GS command in bothpowermon.yamlandpowermon2.yaml:excl_filter: '^(battery_voltage_from_scc.*|mppt2_.*|setting_value_configuration_state)$'Drops 7 always-zero / always-misleading fields:
battery_voltage_from_scc,battery_voltage_from_scc2— no separate SCC bus on this hardwaremppt2_input_voltage,mppt2_input_power,mppt2_charger_temperature,mppt2_charger_status— nothing connected to PV input #2; would auto- resurrect if MPPT2 is ever wiredsetting_value_configuration_state— internal config-write echo, no operational value- kept:
parallel_instance_number(will become useful when parallel comms work) andload_connection(will become live when output is enabled)
-
tmp/lvx-purge-orphansnew tool. Same shape as eg4-purge-orphans: publishes empty retained payloads to the deprecated discovery-config topics so HA forgets the orphans the broker still has cached. Idempotent. paho-mqtt 1.x and 2.x compatible.
Net effect
| Metric | Before | After | Delta |
|---|---|---|---|
| Published state topics per inverter | 29 | 23 | −21 % |
| Total stack (2 inverters) | 58 | 46 | −12 (16 orphans purged) |
| Voltages displayed at integer precision | many | 0 | now show 1 dp |
| Sensors qualified for HA long-term stats | 1 | all numeric | proper trends + Energy dashboard wiring |
Bogus last_reset warnings on HA startup |
58 | 0 | clean log |
| Recorder rows per slow-changing entity / 24h | ~17 k | only on change | DB bloat reduced |
Files touched
A powermon-patches/hass.py (new patch g)
M powermon-patches/pi18.py (patch a tweak: "DC-AC" → "DC AC" in field name)
M powermon-patches/README.md (document patch g)
M install.sh (copy hass.py during install)
M Install.md (§5(g) doc)
A tmp/lvx-purge-orphans (one-shot orphan cleanup)
M config/powermon/powermon.yaml (excl_filter added to GS; password placeholder restored)
M config/powermon/powermon2.yaml (same)
A 2026-04-26.md (this file)
How to verify
# Discovery configs now include precision hint + state_class
mosquitto_sub -h <broker> -u mqtt -P <pass> \
-t 'homeassistant/sensor/lvx6048_1_battery_voltage/config' -W 5 -v
# Expect: ..., "state_class": "measurement", "suggested_display_precision": 1, ...
# Expect: NO "last_reset" or "force_update" fields
# Renamed entity surfaces with underscore
mosquitto_sub -h <broker> -u mqtt -P <pass> \
-t 'homeassistant/sensor/lvx6048_1_dc_ac_power_direction/state' -W 5 -v
# Expect: state value (e.g. "donothing")
# Verify dropped fields are gone
mosquitto_sub -h <broker> -u mqtt -P <pass> \
-t 'homeassistant/sensor/+/state' -W 12 -v \
| grep -E 'lvx6048_._(battery_voltage_from_scc|mppt2|setting_value_configuration|dc-ac)'
# Expect: zero matches
Rollback
# Revert source
git checkout HEAD~1 -- LVX6048/
# Re-apply old patches to live install (the unpatched hass.py comes from pip)
cd LVX6048 && ./install.sh # idempotent, will copy old hass.py back
sudo systemctl restart powermon.service powermon2.service
# Old entities (battery_voltage_from_scc, mppt2_*, etc.) republish on next cycle.