mirror of
https://github.com/home-assistant/core.git
synced 2026-07-13 17:44:45 +01:00
Exclude incompatible water_heater entities from water_heater automations (#169904)
This commit is contained in:
committed by
Franck Nijhof
parent
0c5b02eff3
commit
cc83ee88fb
@@ -76,6 +76,13 @@ class WaterHeaterTargetTemperatureCondition(EntityNumericalConditionWithUnitBase
|
||||
_domain_specs = {DOMAIN: DomainSpec(value_source=ATTR_TEMPERATURE)}
|
||||
_unit_converter = TemperatureConverter
|
||||
|
||||
def _should_include(self, state: State) -> bool:
|
||||
"""Skip water heater entities that do not expose a target temperature."""
|
||||
return (
|
||||
super()._should_include(state)
|
||||
and state.attributes.get(ATTR_TEMPERATURE) is not None
|
||||
)
|
||||
|
||||
def _get_entity_unit(self, entity_state: State) -> str | None:
|
||||
"""Get the temperature unit of a water heater entity from its state."""
|
||||
# Water heater entities convert temperatures to the system unit via show_temp
|
||||
|
||||
@@ -60,6 +60,13 @@ class _WaterHeaterTargetTemperatureTriggerMixin(
|
||||
_domain_specs = {DOMAIN: DomainSpec(value_source=ATTR_TEMPERATURE)}
|
||||
_unit_converter = TemperatureConverter
|
||||
|
||||
def _should_include(self, state: State) -> bool:
|
||||
"""Skip water heater entities that do not expose a target temperature."""
|
||||
return (
|
||||
super()._should_include(state)
|
||||
and state.attributes.get(ATTR_TEMPERATURE) is not None
|
||||
)
|
||||
|
||||
def _get_entity_unit(self, state: State) -> str | None:
|
||||
"""Get the temperature unit of a water heater entity from its state."""
|
||||
# Water heater entities convert temperatures to the system unit via show_temp
|
||||
|
||||
@@ -228,6 +228,7 @@ async def test_water_heater_state_condition_behavior_all(
|
||||
"eco",
|
||||
ATTR_TEMPERATURE,
|
||||
threshold_unit=UnitOfTemperature.CELSIUS,
|
||||
attribute_required=True,
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -267,6 +268,7 @@ async def test_water_heater_numerical_condition_behavior_any(
|
||||
"eco",
|
||||
ATTR_TEMPERATURE,
|
||||
threshold_unit=UnitOfTemperature.CELSIUS,
|
||||
attribute_required=True,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -164,12 +164,14 @@ async def test_water_heater_state_trigger_behavior_any(
|
||||
STATE_ECO,
|
||||
ATTR_TEMPERATURE,
|
||||
threshold_unit=UnitOfTemperature.CELSIUS,
|
||||
attribute_required=True,
|
||||
),
|
||||
*parametrize_numerical_attribute_crossed_threshold_trigger_states(
|
||||
"water_heater.target_temperature_crossed_threshold",
|
||||
STATE_ECO,
|
||||
ATTR_TEMPERATURE,
|
||||
threshold_unit=UnitOfTemperature.CELSIUS,
|
||||
attribute_required=True,
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -270,6 +272,7 @@ async def test_water_heater_state_trigger_behavior_first(
|
||||
STATE_ECO,
|
||||
ATTR_TEMPERATURE,
|
||||
threshold_unit=UnitOfTemperature.CELSIUS,
|
||||
attribute_required=True,
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -370,6 +373,7 @@ async def test_water_heater_state_trigger_behavior_last(
|
||||
STATE_ECO,
|
||||
ATTR_TEMPERATURE,
|
||||
threshold_unit=UnitOfTemperature.CELSIUS,
|
||||
attribute_required=True,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user