Repository navigation
Add read-only HeishaMon heat pump consumer - #4367
kevinwieland wants to merge 4 commits into
Conversation
Read Heat_Power_Consumption and optional inlet, outlet and target temperatures through the local JSON endpoint. Include validation, documentation and regression tests. Companion settings: https://github.com/kevinwieland/openwb-ui-settings/tree/feat/heishamon-consumer
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/modules/consumers/heishamon/heishamon/consumer.py" line_range="13-43" />
<code_context>
+from typing import Optional, Tuple
+
+from control.consumer.consumer_data import ConsumerUsage
+from helpermodules.auto_str import auto_str
</code_context>
<issue_to_address>
**Failed setup leaves polling broken**
When `req.get_http_session()` raises during consumer construction, `ConfigurableConsumer` catches an exception from `initializer()` without retrying it, leaving `session` as `None`; every later `update()` then fails at `session.get()` until the consumer module is recreated.
Retry session initialization after a setup failure, or fail consumer creation instead of retaining a module with an unset session.
</issue_to_address>
### Comment 2
<location path="packages/modules/consumers/heishamon/heishamon/config.py" line_range="12" />
<code_context>
+@auto_str
+class HeishaMonConfiguration:
+ def __init__(self,
+ ip_address: Optional[str] = None,
+ read_temperatures: bool = True):
+ self.ip_address = ip_address
</code_context>
<issue_to_address>
**Missing address prevents polling**
When the consumer is created or loaded with `configuration.ip_address` unset, `update` interpolates the missing address as `None` and requests `http://None/json`; the request fails, so no power or temperatures are reported and the consumer enters a fault state.
Validate that the address is present before constructing the consumer or attempting the request.
Also at `packages/modules/consumers/heishamon/heishamon/consumer.py:43`.
</issue_to_address>
### Comment 3
<location path="packages/modules/consumers/heishamon/heishamon/consumer.py" line_range="59-60" />
<code_context>
+ "Die Wärmepumpe liefert möglicherweise nur erweiterte Leistungswerte.")
+
+ # Keep fixed positions even when one optional sensor is missing or invalid.
+ temperatures = ([_get_temperature(values, name) for name in TEMPERATURE_NAMES]
+ if config.configuration.read_temperatures else None)
+ return ConsumerState(power=power, temperatures=temperatures)
+
</code_context>
<issue_to_address>
**Valid temperatures are discarded**
When at least one optional temperature is missing or invalid, `ConsumerValueStoreBroker` passes the temperature list to `SetData`, which rejects the entire list because its `None` entries fail float validation; no temperature slots reach the consumer state.
Allow `None` entries in temperature collections through `SetData` validation and storage while retaining the fixed slots.
</issue_to_address>
### Comment 4
<location path="packages/modules/consumers/heishamon/heishamon/consumer.py" line_range="61" />
<code_context>
+ # Keep fixed positions even when one optional sensor is missing or invalid.
+ temperatures = ([_get_temperature(values, name) for name in TEMPERATURE_NAMES]
+ if config.configuration.read_temperatures else None)
+ return ConsumerState(power=power, temperatures=temperatures)
+
+ return ConfigurableConsumer(consumer_config=config,
</code_context>
<issue_to_address>
**Unmeasured phases are stored as zero**
`ConsumerState` fills omitted phase measurements with zero currents and powers and default voltages; `ConsumerValueStoreBroker` publishes those values, so phase data is recorded even though HeishaMon supplied no phase measurements.
Avoid publishing phase measurements for this consumer unless the module actually reads them.
</issue_to_address>
### Comment 5
<location path="packages/modules/consumers/heishamon/heishamon/consumer.py" line_range="59-60" />
<code_context>
+ "Die Wärmepumpe liefert möglicherweise nur erweiterte Leistungswerte.")
+
+ # Keep fixed positions even when one optional sensor is missing or invalid.
+ temperatures = ([_get_temperature(values, name) for name in TEMPERATURE_NAMES]
+ if config.configuration.read_temperatures else None)
+ return ConsumerState(power=power, temperatures=temperatures)
+
</code_context>
<issue_to_address>
**Old temperatures remain visible**
When temperature readings are disabled after a temperature value has been published, `ConsumerValueStoreBroker` skips publishing `None`, so the previously published temperature value remains stored and appears current.
Clear or remove the published temperature value when readings are disabled instead of skipping the `None` update.
Also at `packages/modules/consumers/heishamon/heishamon/consumer.py:61`.
</issue_to_address>| # Keep fixed positions even when one optional sensor is missing or invalid. | ||
| temperatures = ([_get_temperature(values, name) for name in TEMPERATURE_NAMES] | ||
| if config.configuration.read_temperatures else None) | ||
| return ConsumerState(power=power, temperatures=temperatures) |
There was a problem hiding this comment.
🟡 Medium · Unmeasured phases are stored as zero
ConsumerState fills omitted phase measurements with zero currents and powers and default voltages; ConsumerValueStoreBroker publishes those values, so phase data is recorded even though HeishaMon supplied no phase measurements.
Avoid publishing phase measurements for this consumer unless the module actually reads them.
Prompt for AI agents
In `packages/modules/consumers/heishamon/heishamon/consumer.py` at line 61:
**Unmeasured phases are stored as zero**
`ConsumerState` fills omitted phase measurements with zero currents and powers and default voltages; `ConsumerValueStoreBroker` publishes those values, so phase data is recorded even though HeishaMon supplied no phase measurements.
Avoid publishing phase measurements for this consumer unless the module actually reads them.Validate the host before polling, retry failed HTTP-session initialization, preserve nullable temperature slots through the consumer validator, and clear temperatures when disabled. Leave phase handling unchanged.
|
Ein paar Kommentare mit Hinblick auf alle anderen Consumer Module: :)
Als Anhaltspunkt, wie
|
Always read available temperatures, use the common HTTP helper directly, and rely on standard conversion and error handling. Keep invalid negative power readings rejected and nullable temperature slots intact.
|
Danke @seaspotter, die Vereinfachungen sind in a2d52ee und im UI-PR openWB/openwb-ui-settings#1180 (d95caf5) umgesetzt:
Die fachliche Prüfung auf negative elektrische Leistungswerte bleibt wegen ungültiger HeishaMon-Werte wie -200 W erhalten. Die Unterstützung von None innerhalb der Temperaturliste bleibt ebenfalls bestehen, damit fehlende Sensorwerte nicht die anderen Temperaturen verwerfen. Die Phasenbehandlung ist unverändert. 181 bestehende Core-Tests, 36 lokale Prüfungen sowie 61 bestehende UI-Tests erfolgreich; Lint und UI-Build ebenfalls erfolgreich. Keine Testdateien, README oder Build-Artefakte in den PRs ergänzt. |
Add read-only HeishaMon heat pump consumer
Summary
METER_ONLY./jsonHTTP endpoint once per update with a five-second timeout.Heat_Power_Consumptionin watts.Main_Inlet_Temp,Main_Outlet_Temp, andMain_Target_Tempin this fixed order whenever supplied, without a separate configuration toggle.
or invalid optional temperature slots as
null.reflect that in the consumer data type; phase-value validation is unchanged.
handling report request, JSON and conversion failures.
No heat pump commands, control features, phase-current estimates, or sums across
operating modes are introduced. Extra-block-only power layouts are explicitly
outside the scope of this module. Energy counters use the existing core integration.
Related UI change
Companion settings PR: openWB/openwb-ui-settings#1180
The core also works with the existing JSON configuration fallback until the
companion UI is published. No compiled frontend assets are included here.
Validation
unsupported power values, nullable temperatures through broker validation and
storage, missing sensors replacing old readings, and per-poll HTTP sessions.
Summary by Sourcery
Add read-only HeishaMon monitoring for Panasonic heat pumps with robust power and temperature handling.
New Features:
Bug Fixes:
Enhancements: