Generic thermostat: propagate unavailable sensor state and add sensor error actions#167290
Generic thermostat: propagate unavailable sensor state and add sensor error actions#167290akshimassar wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Hi @akshimassar
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
There was a problem hiding this comment.
Pull request overview
This PR improves generic thermostat behavior when a temperature sensor becomes unavailable at runtime by:
- Propagating sensor unavailability: Sets
current_temperaturetoNonewhen the sensor state becomes unavailable, unknown, or invalid (e.g., NaN, Inf) - Configurable error handling: Introduces a
sensor_error_actionoption with three modes:keep(default): Maintains current behavior without forcing any actionforce_off: Forces the actuator off when sensor is unavailableforce_on: Forces the actuator on when sensor is unavailable
- Integrated control path: Sensor error actions map to the existing
too_cold/too_hotcontrol logic, preserving keep-alive, cooldown/min-cycle, and max-cycle handling - Enhanced visibility: Adds
sensor_errorandsensor_error_actionattributes to the climate entity state for monitoring
Changes:
- Added sensor error action constants and configuration options
- Modified temperature update logic to propagate unavailability instead of silently ignoring it
- Implemented sensor error tolerance computation based on configured action
- Added config flow support with translated selector labels
- Comprehensive test coverage including runtime unavailability, action behavior, mode-off scenarios, and keep-alive/max-cycle interactions
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| homeassistant/components/generic_thermostat/const.py | Adds constants for sensor error actions and default behavior |
| homeassistant/components/generic_thermostat/config_flow.py | Integrates sensor_error_action selector into configuration flow with translation support |
| homeassistant/components/generic_thermostat/climate.py | Implements sensor unavailability propagation, error action handling, and control logic updates |
| homeassistant/components/generic_thermostat/strings.json | Provides translated labels for sensor error action options and configuration fields |
| tests/components/generic_thermostat/test_climate.py | Adds comprehensive tests for unavailability handling, error actions, and timer behavior |
| tests/components/generic_thermostat/test_config_flow.py | Updates config flow tests to include new sensor error action option |
| tests/components/generic_thermostat/snapshots/test_config_flow.ambr | Updates snapshots to include new state attributes |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Set current_temperature to None when the target sensor becomes unavailable or unknown at runtime, so climate state reflects sensor availability. Add regression tests covering runtime propagation and ensuring keep_alive callbacks and max_cycle_duration shutdown are still honored while the sensor is unavailable.
Introduce configurable behavior for sensor-unavailable states via keep/force_on/force_off actions while preserving existing cycle and keep-alive control paths. Surface the option in config flows and add regression coverage for runtime behavior and snapshots.
ea2c6e3 to
0dad262
Compare
|
I've rebased upon latest dev branch. Still would like to merge it. |
Breaking change
Proposed change
This PR improves
generic_thermostatbehavior when the temperature sensor becomes unavailable at runtime.current_temperaturetoNonewhen sensor state is unavailable, unknown, or invalid.sensor_error_actionwith values:keep(default, preserves current behavior)force_offforce_onsensor_error_actioninto the existing control path by mapping totoo_cold/too_hot, so keep-alive, cooldown/min-cycle, and max-cycle handling are still honored.Rationale
Thermostat failures can be safety-relevant, and wireless sensor loss is a realistic failure mode.
In my setup, a garage temperature sensor lost connectivity while the actuator was off. The thermostat still appeared healthy (idle, last known temperature above target), but the real garage temperature continued to fall.
This PR addresses two user-facing risks:
current_temperaturenow reflects that instead of continuing to expose stale data. This allows monitoring/alerts to react correctly.force_offmay be safest to reduce overheating risk.force_onmay be safest to reduce freezing risk.keepremains available and, with unavailable temperature propagation, now respects max-cycle limits instead of reactivating from stale temperature input.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: