Add TARGET_TEMPERATURE to water_heater state attributes (#180022)

This commit is contained in:
epenet
2026-08-24 22:12:45 +02:00
committed by GitHub
parent 1d8dcf4176
commit 086c500857
22 changed files with 50 additions and 38 deletions
@@ -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)
@@ -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,
}
@@ -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",
)
@@ -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,
@@ -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
+11 -2
View File
@@ -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"
@@ -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,
@@ -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,
@@ -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
@@ -50,7 +50,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 5>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 130,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 130,
}),
'context': <ANY>,
'entity_id': 'water_heater.basement_my_water_heater',
@@ -122,7 +122,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 7>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 130,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 130,
}),
'context': <ANY>,
'entity_id': 'water_heater.basement_my_water_heater',
@@ -60,7 +60,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 11>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 50.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 50.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.water_heater',
@@ -62,7 +62,7 @@
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterCapabilityAttribute.TARGET_TEMP_STEP: 'target_temp_step'>: 1,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 55.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 55.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.r_900',
@@ -55,7 +55,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 14>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: None,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: None,
}),
'context': <ANY>,
'entity_id': 'water_heater.domestic_hot_water',
@@ -101,7 +101,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 14>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: None,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: None,
}),
'context': <ANY>,
'entity_id': 'water_heater.domestic_hot_water',
@@ -69,7 +69,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 3>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 60,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 60,
}),
'context': <ANY>,
'entity_id': 'water_heater.hot_water',
@@ -58,7 +58,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 3>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 50.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 50.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.qube_heat_pump_domestic_hot_water',
@@ -52,7 +52,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 0>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: None,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: None,
}),
'context': <ANY>,
'entity_id': 'water_heater.boiler',
@@ -60,7 +60,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 11>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 65,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 65,
}),
'context': <ANY>,
'entity_id': 'water_heater.water_heater',
@@ -50,7 +50,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 13>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: 63,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: 57,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 60,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 60,
}),
'context': <ANY>,
'entity_id': 'water_heater.test_device',
@@ -61,7 +61,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 7>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 60.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 60.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.my_home_patio_water_heating',
@@ -137,7 +137,7 @@
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterCapabilityAttribute.TARGET_TEMP_STEP: 'target_temp_step'>: 4.0,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 45.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 45.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.my_home_water_heater',
@@ -208,7 +208,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 3>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 54,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 54,
}),
'context': <ANY>,
'entity_id': 'water_heater.somfy_tahoma_switch_yutaki_dhw',
@@ -65,7 +65,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 14>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: 69,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: 38,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 56,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 56,
}),
'context': <ANY>,
'entity_id': 'water_heater.heat_pump',
@@ -139,7 +139,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 14>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: 55,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: 40,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 48,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 48,
}),
'context': <ANY>,
'entity_id': 'water_heater.eco_heating_system',
@@ -215,7 +215,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 15>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: 57,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: 40,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 52,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 52,
}),
'context': <ANY>,
'entity_id': 'water_heater.warmepumpe',
@@ -60,7 +60,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 3>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 30.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 30.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.second_water_heater_second_water_heater',
@@ -131,7 +131,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 3>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: 65.0,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: 65.0,
}),
'context': <ANY>,
'entity_id': 'water_heater.water_heater_water_heater',
@@ -49,7 +49,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 1>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: None,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: None,
}),
'context': <ANY>,
'entity_id': 'water_heater.model0_domestic_hot_water',
@@ -109,7 +109,7 @@
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <WaterHeaterEntityFeature: 1>,
<WaterHeaterStateAttribute.TARGET_TEMP_HIGH: 'target_temp_high'>: None,
<WaterHeaterStateAttribute.TARGET_TEMP_LOW: 'target_temp_low'>: None,
<WaterHeaterStateAttribute.TEMPERATURE: 'temperature'>: None,
<WaterHeaterStateAttribute.TARGET_TEMPERATURE: 'temperature'>: None,
}),
'context': <ANY>,
'entity_id': 'water_heater.model0_domestic_hot_water_2',