Cleaned up inverter mqtt

This commit is contained in:
2026-04-26 08:49:05 -04:00
parent b526b10cf5
commit f771ec2b46
9 changed files with 367 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ Each file below lands at the indicated path — the top-level `install.sh` does
| `mqttbroker.py` | `libs/mqttbroker.py` | (c) broaden `connect()`'s `except ConnectionRefusedError` to `(ConnectionRefusedError, OSError)` and narrow `publish()`'s bare `except Exception` to `(OSError, RuntimeError, ValueError)`. Otherwise any broker blip (HA restart, `Errno 113 No route to host`) crashes the daemon. |
| `port_config_model.py` | `configmodel/port_config_model.py` | (e) add `serial_number: None \| str \| int = Field(default=None)` to `UsbPortConfig`. The model is `NoExtraBaseModel`, so powermon rejects `serial_number:` at the port level without this. |
| `ports_init.py` | `ports/__init__.py` | (f) in `from_config()`, make `port_config['serial_number'] = serial_number` a fallback (`if port_config.get('serial_number') is None:`). Device-level `serial_number` is the HA identifier (e.g. `lvx6048_1`); the port-level one is the hardware PI18 serial — they must not be conflated. |
| `hass.py` | `outputformats/hass.py` | (g) cleaner HA-discovery payload: drop bogus `last_reset` (HA spec for `total` only, not `measurement`); drop default `force_update: "true"` (causes recorder bloat on slow-changing fields); add `suggested_display_precision` per-unit (so HA frontend doesn't truncate `52.5 V``52 V`); default `state_class: measurement` for numeric sensors (required for HA long-term stats + Energy dashboard). |
Patches (a)(d) are load-bearing for the live setup. Patches (e) and (f) enable
powermon's native wildcard-path + serial-matching flow for a single-daemon