From 086c5008572e1b1aa5a17cf024db0c07db1cdfe4 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 24 Aug 2026 22:12:45 +0200 Subject: [PATCH] Add TARGET_TEMPERATURE to water_heater state attributes (#180022) --- .../components/homekit/type_thermostats.py | 2 +- homeassistant/components/mqtt/water_heater.py | 2 +- homeassistant/components/prometheus/__init__.py | 2 +- homeassistant/components/water_heater/__init__.py | 2 +- homeassistant/components/water_heater/condition.py | 5 +++-- homeassistant/components/water_heater/const.py | 13 +++++++++++-- .../components/water_heater/reproduce_state.py | 13 +++++++------ .../components/water_heater/significant_change.py | 2 +- homeassistant/components/water_heater/trigger.py | 5 +++-- .../aosmith/snapshots/test_water_heater.ambr | 4 ++-- .../bsblan/snapshots/test_water_heater.ambr | 2 +- .../compit/snapshots/test_water_heater.ambr | 2 +- .../evohome/snapshots/test_water_heater.ambr | 4 ++-- .../geniushub/snapshots/test_water_heater.ambr | 2 +- .../hr_energy_qube/snapshots/test_water_heater.ambr | 2 +- .../incomfort/snapshots/test_water_heater.ambr | 2 +- .../matter/snapshots/test_water_heater.ambr | 2 +- .../osoenergy/snapshots/test_water_heater.ambr | 2 +- .../overkiz/snapshots/test_water_heater.ambr | 6 +++--- .../smartthings/snapshots/test_water_heater.ambr | 6 +++--- .../tado/snapshots/test_water_heater.ambr | 4 ++-- .../vicare/snapshots/test_water_heater.ambr | 4 ++-- 22 files changed, 50 insertions(+), 38 deletions(-) diff --git a/homeassistant/components/homekit/type_thermostats.py b/homeassistant/components/homekit/type_thermostats.py index bb025bd602c4..0f480ef2b7e7 100644 --- a/homeassistant/components/homekit/type_thermostats.py +++ b/homeassistant/components/homekit/type_thermostats.py @@ -680,7 +680,7 @@ class WaterHeater(HomeAccessory): """Update water_heater state after state change.""" # Update current and target temperature target_temperature = temperature_attribute_to_homekit( - new_state, WaterHeaterStateAttribute.TEMPERATURE, self._unit + new_state, WaterHeaterStateAttribute.TARGET_TEMPERATURE, self._unit ) if target_temperature is not None: self.char_target_temp.set_value(target_temperature) diff --git a/homeassistant/components/mqtt/water_heater.py b/homeassistant/components/mqtt/water_heater.py index 2575158a6a31..1f48c357cab3 100644 --- a/homeassistant/components/mqtt/water_heater.py +++ b/homeassistant/components/mqtt/water_heater.py @@ -81,7 +81,7 @@ MQTT_WATER_HEATER_ATTRIBUTES_BLOCKED = frozenset( WaterHeaterStateAttribute.CURRENT_TEMPERATURE, WaterHeaterCapabilityAttribute.MAX_TEMP, WaterHeaterCapabilityAttribute.MIN_TEMP, - WaterHeaterStateAttribute.TEMPERATURE, + WaterHeaterStateAttribute.TARGET_TEMPERATURE, WaterHeaterCapabilityAttribute.OPERATION_LIST, WaterHeaterStateAttribute.OPERATION_MODE, } diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index d2d9b6af670d..d747c7b79aa1 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -927,7 +927,7 @@ class PrometheusMetrics: # Temperatures self._temperature_metric( state, - WaterHeaterStateAttribute.TEMPERATURE, + WaterHeaterStateAttribute.TARGET_TEMPERATURE, "water_heater_temperature_celsius", "Target temperature in degrees Celsius", ) diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index d1671fceecae..e67343474170 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -230,7 +230,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): self.temperature_unit, self.precision, ), - WaterHeaterStateAttribute.TEMPERATURE: show_temp( + WaterHeaterStateAttribute.TARGET_TEMPERATURE: show_temp( self.hass, self.target_temperature, self.temperature_unit, diff --git a/homeassistant/components/water_heater/condition.py b/homeassistant/components/water_heater/condition.py index 3d11d13982a7..b6f51a348fd6 100644 --- a/homeassistant/components/water_heater/condition.py +++ b/homeassistant/components/water_heater/condition.py @@ -69,7 +69,7 @@ class WaterHeaterTargetTemperatureCondition(EntityNumericalConditionWithUnitBase _base_unit = UnitOfTemperature.CELSIUS _domain_specs = { - DOMAIN: DomainSpec(value_source=WaterHeaterStateAttribute.TEMPERATURE) + DOMAIN: DomainSpec(value_source=WaterHeaterStateAttribute.TARGET_TEMPERATURE) } _unit_converter = TemperatureConverter @@ -78,7 +78,8 @@ class WaterHeaterTargetTemperatureCondition(EntityNumericalConditionWithUnitBase """Skip water heater entities that do not expose a target temperature.""" return ( super()._should_include(state) - and state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) is not None + and state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) + is not None ) @override diff --git a/homeassistant/components/water_heater/const.py b/homeassistant/components/water_heater/const.py index fb5ac3afa93d..df29dabd0589 100644 --- a/homeassistant/components/water_heater/const.py +++ b/homeassistant/components/water_heater/const.py @@ -2,6 +2,8 @@ from enum import StrEnum +from homeassistant.helpers.deprecation import EnumWithDeprecatedMembers + DOMAIN = "water_heater" @@ -14,11 +16,18 @@ class WaterHeaterCapabilityAttribute(StrEnum): OPERATION_LIST = "operation_list" -class WaterHeaterStateAttribute(StrEnum): +class WaterHeaterStateAttribute( + StrEnum, + metaclass=EnumWithDeprecatedMembers, + deprecated={ + "TEMPERATURE": ("ClimateEntityStateAttribute.TARGET_TEMPERATURE", "2027.3.0"), + }, +): """State attributes for water heater entities.""" CURRENT_TEMPERATURE = "current_temperature" - TEMPERATURE = "temperature" + TARGET_TEMPERATURE = "temperature" + TEMPERATURE = "temperature" # Deprecated, replaced with TARGET_TEMPERATURE TARGET_TEMP_HIGH = "target_temp_high" TARGET_TEMP_LOW = "target_temp_low" OPERATION_MODE = "operation_mode" diff --git a/homeassistant/components/water_heater/reproduce_state.py b/homeassistant/components/water_heater/reproduce_state.py index 7f22fa399061..889ed8c3855e 100644 --- a/homeassistant/components/water_heater/reproduce_state.py +++ b/homeassistant/components/water_heater/reproduce_state.py @@ -66,8 +66,8 @@ async def _async_reproduce_state( # Return if we are already at the right state. if ( cur_state.state == state.state - and cur_state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) - == state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) + and cur_state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) + == state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) and cur_state.attributes.get(WaterHeaterStateAttribute.AWAY_MODE) == state.attributes.get(WaterHeaterStateAttribute.AWAY_MODE) ): @@ -89,9 +89,10 @@ async def _async_reproduce_state( ) if ( - state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) - != cur_state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) - and state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) is not None + state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) + != cur_state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) + and state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) + is not None ): await hass.services.async_call( DOMAIN, @@ -99,7 +100,7 @@ async def _async_reproduce_state( { ATTR_ENTITY_ID: state.entity_id, ATTR_TEMPERATURE: state.attributes.get( - WaterHeaterStateAttribute.TEMPERATURE + WaterHeaterStateAttribute.TARGET_TEMPERATURE ), }, context=context, diff --git a/homeassistant/components/water_heater/significant_change.py b/homeassistant/components/water_heater/significant_change.py index a322402ddfbd..202be6e6f776 100644 --- a/homeassistant/components/water_heater/significant_change.py +++ b/homeassistant/components/water_heater/significant_change.py @@ -13,7 +13,7 @@ from .const import WaterHeaterStateAttribute SIGNIFICANT_ATTRIBUTES: set[str] = { WaterHeaterStateAttribute.CURRENT_TEMPERATURE, - WaterHeaterStateAttribute.TEMPERATURE, + WaterHeaterStateAttribute.TARGET_TEMPERATURE, WaterHeaterStateAttribute.TARGET_TEMP_HIGH, WaterHeaterStateAttribute.TARGET_TEMP_LOW, WaterHeaterStateAttribute.OPERATION_MODE, diff --git a/homeassistant/components/water_heater/trigger.py b/homeassistant/components/water_heater/trigger.py index 8d692e396e60..2fa0063fd63d 100644 --- a/homeassistant/components/water_heater/trigger.py +++ b/homeassistant/components/water_heater/trigger.py @@ -57,7 +57,7 @@ class _WaterHeaterTargetTemperatureTriggerMixin( _base_unit = UnitOfTemperature.CELSIUS _domain_specs = { - DOMAIN: DomainSpec(value_source=WaterHeaterStateAttribute.TEMPERATURE) + DOMAIN: DomainSpec(value_source=WaterHeaterStateAttribute.TARGET_TEMPERATURE) } _unit_converter = TemperatureConverter @@ -66,7 +66,8 @@ class _WaterHeaterTargetTemperatureTriggerMixin( """Skip water heater entities that do not expose a target temperature.""" return ( super()._should_include(state) - and state.attributes.get(WaterHeaterStateAttribute.TEMPERATURE) is not None + and state.attributes.get(WaterHeaterStateAttribute.TARGET_TEMPERATURE) + is not None ) @override diff --git a/tests/components/aosmith/snapshots/test_water_heater.ambr b/tests/components/aosmith/snapshots/test_water_heater.ambr index b09281eba84b..3c769b6afce5 100644 --- a/tests/components/aosmith/snapshots/test_water_heater.ambr +++ b/tests/components/aosmith/snapshots/test_water_heater.ambr @@ -50,7 +50,7 @@ : , : None, : None, - : 130, + : 130, }), 'context': , 'entity_id': 'water_heater.basement_my_water_heater', @@ -122,7 +122,7 @@ : , : None, : None, - : 130, + : 130, }), 'context': , 'entity_id': 'water_heater.basement_my_water_heater', diff --git a/tests/components/bsblan/snapshots/test_water_heater.ambr b/tests/components/bsblan/snapshots/test_water_heater.ambr index 2f7e25b1490a..9d2703668b0c 100644 --- a/tests/components/bsblan/snapshots/test_water_heater.ambr +++ b/tests/components/bsblan/snapshots/test_water_heater.ambr @@ -60,7 +60,7 @@ : , : None, : None, - : 50.0, + : 50.0, }), 'context': , 'entity_id': 'water_heater.water_heater', diff --git a/tests/components/compit/snapshots/test_water_heater.ambr b/tests/components/compit/snapshots/test_water_heater.ambr index 0aa2155f19db..c2c119885db1 100644 --- a/tests/components/compit/snapshots/test_water_heater.ambr +++ b/tests/components/compit/snapshots/test_water_heater.ambr @@ -62,7 +62,7 @@ : None, : None, : 1, - : 55.0, + : 55.0, }), 'context': , 'entity_id': 'water_heater.r_900', diff --git a/tests/components/evohome/snapshots/test_water_heater.ambr b/tests/components/evohome/snapshots/test_water_heater.ambr index 3ef2448f5b86..ab0712d4161d 100644 --- a/tests/components/evohome/snapshots/test_water_heater.ambr +++ b/tests/components/evohome/snapshots/test_water_heater.ambr @@ -55,7 +55,7 @@ : , : None, : None, - : None, + : None, }), 'context': , 'entity_id': 'water_heater.domestic_hot_water', @@ -101,7 +101,7 @@ : , : None, : None, - : None, + : None, }), 'context': , 'entity_id': 'water_heater.domestic_hot_water', diff --git a/tests/components/geniushub/snapshots/test_water_heater.ambr b/tests/components/geniushub/snapshots/test_water_heater.ambr index f36571cb02c3..4109f0496714 100644 --- a/tests/components/geniushub/snapshots/test_water_heater.ambr +++ b/tests/components/geniushub/snapshots/test_water_heater.ambr @@ -69,7 +69,7 @@ : , : None, : None, - : 60, + : 60, }), 'context': , 'entity_id': 'water_heater.hot_water', diff --git a/tests/components/hr_energy_qube/snapshots/test_water_heater.ambr b/tests/components/hr_energy_qube/snapshots/test_water_heater.ambr index fcc43036f266..282d3f667958 100644 --- a/tests/components/hr_energy_qube/snapshots/test_water_heater.ambr +++ b/tests/components/hr_energy_qube/snapshots/test_water_heater.ambr @@ -58,7 +58,7 @@ : , : None, : None, - : 50.0, + : 50.0, }), 'context': , 'entity_id': 'water_heater.qube_heat_pump_domestic_hot_water', diff --git a/tests/components/incomfort/snapshots/test_water_heater.ambr b/tests/components/incomfort/snapshots/test_water_heater.ambr index bfffb403dfa5..aca7ff6d87b5 100644 --- a/tests/components/incomfort/snapshots/test_water_heater.ambr +++ b/tests/components/incomfort/snapshots/test_water_heater.ambr @@ -52,7 +52,7 @@ : , : None, : None, - : None, + : None, }), 'context': , 'entity_id': 'water_heater.boiler', diff --git a/tests/components/matter/snapshots/test_water_heater.ambr b/tests/components/matter/snapshots/test_water_heater.ambr index 49c8482b4250..88c07fcb6f5f 100644 --- a/tests/components/matter/snapshots/test_water_heater.ambr +++ b/tests/components/matter/snapshots/test_water_heater.ambr @@ -60,7 +60,7 @@ : , : None, : None, - : 65, + : 65, }), 'context': , 'entity_id': 'water_heater.water_heater', diff --git a/tests/components/osoenergy/snapshots/test_water_heater.ambr b/tests/components/osoenergy/snapshots/test_water_heater.ambr index 082a77cacb20..6859adf22897 100644 --- a/tests/components/osoenergy/snapshots/test_water_heater.ambr +++ b/tests/components/osoenergy/snapshots/test_water_heater.ambr @@ -50,7 +50,7 @@ : , : 63, : 57, - : 60, + : 60, }), 'context': , 'entity_id': 'water_heater.test_device', diff --git a/tests/components/overkiz/snapshots/test_water_heater.ambr b/tests/components/overkiz/snapshots/test_water_heater.ambr index e6ffaf03aeef..a794aabaae40 100644 --- a/tests/components/overkiz/snapshots/test_water_heater.ambr +++ b/tests/components/overkiz/snapshots/test_water_heater.ambr @@ -61,7 +61,7 @@ : , : None, : None, - : 60.0, + : 60.0, }), 'context': , 'entity_id': 'water_heater.my_home_patio_water_heating', @@ -137,7 +137,7 @@ : None, : None, : 4.0, - : 45.0, + : 45.0, }), 'context': , 'entity_id': 'water_heater.my_home_water_heater', @@ -208,7 +208,7 @@ : , : None, : None, - : 54, + : 54, }), 'context': , 'entity_id': 'water_heater.somfy_tahoma_switch_yutaki_dhw', diff --git a/tests/components/smartthings/snapshots/test_water_heater.ambr b/tests/components/smartthings/snapshots/test_water_heater.ambr index 2daa1f6b878f..98b935550bcd 100644 --- a/tests/components/smartthings/snapshots/test_water_heater.ambr +++ b/tests/components/smartthings/snapshots/test_water_heater.ambr @@ -65,7 +65,7 @@ : , : 69, : 38, - : 56, + : 56, }), 'context': , 'entity_id': 'water_heater.heat_pump', @@ -139,7 +139,7 @@ : , : 55, : 40, - : 48, + : 48, }), 'context': , 'entity_id': 'water_heater.eco_heating_system', @@ -215,7 +215,7 @@ : , : 57, : 40, - : 52, + : 52, }), 'context': , 'entity_id': 'water_heater.warmepumpe', diff --git a/tests/components/tado/snapshots/test_water_heater.ambr b/tests/components/tado/snapshots/test_water_heater.ambr index 83d74827f9bc..7776ec1d9974 100644 --- a/tests/components/tado/snapshots/test_water_heater.ambr +++ b/tests/components/tado/snapshots/test_water_heater.ambr @@ -60,7 +60,7 @@ : , : None, : None, - : 30.0, + : 30.0, }), 'context': , 'entity_id': 'water_heater.second_water_heater_second_water_heater', @@ -131,7 +131,7 @@ : , : None, : None, - : 65.0, + : 65.0, }), 'context': , 'entity_id': 'water_heater.water_heater_water_heater', diff --git a/tests/components/vicare/snapshots/test_water_heater.ambr b/tests/components/vicare/snapshots/test_water_heater.ambr index cbdf0cd72fd3..77d70d44761c 100644 --- a/tests/components/vicare/snapshots/test_water_heater.ambr +++ b/tests/components/vicare/snapshots/test_water_heater.ambr @@ -49,7 +49,7 @@ : , : None, : None, - : None, + : None, }), 'context': , 'entity_id': 'water_heater.model0_domestic_hot_water', @@ -109,7 +109,7 @@ : , : None, : None, - : None, + : None, }), 'context': , 'entity_id': 'water_heater.model0_domestic_hot_water_2',