TempSensor: new device class, loadpoint temperature override for heating devices - #33673
TempSensor: new device class, loadpoint temperature override for heating devices#33673andig wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="server/http_config_device_handler.go" line_range="702-704" />
<code_context>
+ // cleanup references
+ for _, dev := range h.Devices() {
+ lp := dev.Instance()
+ if lp != nil && lp.GetThermometerRef() == config.NameForID(id) {
+ lp.SetThermometerRef("")
+ }
+ }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Deleting a thermometer clears only the loadpoint's configured reference; `SetThermometerRef` does not clear the already-loaded `lp.thermometer` instance, so the running loadpoint continues reading the deleted thermometer until it is restarted or reconstructed.
**Triggers:** When a thermometer referenced by a running loadpoint is deleted.
**Suggested fix:** Clear the runtime thermometer pointer as part of reference removal, or reload/reconfigure the affected loadpoint after deleting the device.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and this adds a persisted thermometer reference and uses its readings to override the heating device's temperature and SOC/limit reporting, so an incorrect reading could cause bounded but incorrect runtime heating or charging behavior. Reverting removes the new behavior, while any incorrect configuration already saved would need to be corrected or cleared.
Blocking findings: server/http_config_device_handler.go:704
| if lp != nil && lp.GetThermometerRef() == config.NameForID(id) { | ||
| lp.SetThermometerRef("") | ||
| } |
There was a problem hiding this comment.
issue (bug_risk): Deleting a thermometer clears only the loadpoint's configured reference; SetThermometerRef does not clear the already-loaded lp.thermometer instance, so the running loadpoint continues reading the deleted thermometer until it is restarted or reconstructed.
Triggers: When a thermometer referenced by a running loadpoint is deleted.
Suggested fix: Clear the runtime thermometer pointer as part of reference removal, or reload/reconfigure the affected loadpoint after deleting the device.
Code reviewFound one issue worth a look before merge.
Lines 2151 to 2172 in 20dc4d5 When if socR == nil && (lp.vehicleSocPollAllowed() || lp.chargerHasFeature(api.IntegratedDevice)) {
var socErr error
socR, limitR, socErr = socAndLimit("vehicle", lp.GetVehicle())unconditionally overwrites Net effect: on a heating loadpoint with a temp sensor configured, a single transient temp-sensor read error while charging silently discards the charger's limit temperature for that cycle (affects |
|
@naltatis not sure if this is worth it? |
…ting devices Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
10d17b1 to
57fa961
Compare
Ref #33175
Adds a
tempsensordevice class. A temp sensor implementsapi.Battery(Soc = temperature in °C) from a configuredtempplugin, so an external sensor (Shelly, Home Assistant, MQTT, ...) can drive a heating loadpoint whose charger has no temperature input.Backend
templates.TempSensorclass,templates/definition/tempsensor/(Home Assistant template), custom yaml type withtemp:pluginconfig.TempSensors()registry,tempsensors:yaml key, setup/delete/dump wiring, config device API handlers (/config/devices/tempsensor)tempSensor:reference (static config, API, settings key). When set, the sensor's temperature replaces the charger'sapi.Batteryreading inpublishSocAndRange; the charger'sSocLimiter(limit temperature) is still used. Loadpoint delete/disable propagate to the owned sensor like the charge meter.UI
TempSensorModal(template + custom yaml)Not included: Playwright test, evcc-docs
user-defined-devices#tempsensorsection.🤖 Generated with Claude Code