111 lines
4.8 KiB
Markdown
111 lines
4.8 KiB
Markdown
# 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
|
||
|
||
1. **New patch (g) — `outputformats/hass.py`.** Rewrites powermon's HA
|
||
discovery-payload assembly so:
|
||
- `suggested_display_precision` is set per unit (V/A → 1 dp,
|
||
W/VA/% → 0, °C → 0, Hz → 1, Ah → 1, etc.). Frontend now renders
|
||
`52.5 V` instead of `52 V`.
|
||
- `state_class: measurement` is set by default for numeric sensors
|
||
that don't have an explicit class. Required for HA's long-term
|
||
statistics + Energy dashboard wiring; previously only
|
||
`ac_output_active_power` had it.
|
||
- `last_reset: <datetime>` removed from every payload. HA spec
|
||
allows it only on `state_class: total` cumulative counters; on
|
||
`measurement` sensors 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).
|
||
|
||
2. **Patch (a) tweak.** `"DC-AC power direction"` → `"DC AC power
|
||
direction"`. Causes the HA entity_id to become `dc_ac_power_direction`
|
||
(underscore, conforming) rather than the previous `dc-ac_power_direction`
|
||
(hyphen, non-conforming).
|
||
|
||
3. **`excl_filter` added to GS command** in both `powermon.yaml` and
|
||
`powermon2.yaml`:
|
||
```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 hardware
|
||
- `mppt2_input_voltage`, `mppt2_input_power`, `mppt2_charger_temperature`,
|
||
`mppt2_charger_status` — nothing connected to PV input #2; would auto-
|
||
resurrect if MPPT2 is ever wired
|
||
- `setting_value_configuration_state` — internal config-write echo, no
|
||
operational value
|
||
- **kept**: `parallel_instance_number` (will become useful when parallel
|
||
comms work) and `load_connection` (will become live when output is
|
||
enabled)
|
||
|
||
4. **`tmp/lvx-purge-orphans` new 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
|
||
|
||
```bash
|
||
# 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
|
||
|
||
```bash
|
||
# 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.
|
||
```
|