diff --git a/custom_components/hvac_group/climate.py b/custom_components/hvac_group/climate.py index 2965895..b205865 100644 --- a/custom_components/hvac_group/climate.py +++ b/custom_components/hvac_group/climate.py @@ -26,6 +26,8 @@ CONF_NAME, PRECISION_HALVES, PRECISION_TENTHS, + STATE_UNAVAILABLE, + STATE_UNKNOWN, ) from homeassistant.core import HomeAssistant, State, callback from homeassistant.helpers import entity_registry as er @@ -211,6 +213,21 @@ def __init__( self._require_actuator_mass_refresh: bool = False self._old_state: State | None = None + @property + def available(self) -> bool: + """Return climate group availability.""" + return ( + (self._current_temperature is not None) + and (len(self._attr_hvac_modes) > 0) + and ( + self._target_temperature is not None + or ( + self._target_temp_high is not None + and self._target_temp_low is not None + ) + ) + ) + @property def current_temperature(self) -> float | None: """Return the sensor temperature.""" @@ -566,6 +583,9 @@ async def async_update_temperature_sensor( if new_state is None: return + if new_state.state in (None, STATE_UNAVAILABLE, STATE_UNKNOWN): + return + # Current temperature can be retrieved from a `climate` or `sensor` entity new_temperature = ( new_state.attributes.get(ATTR_CURRENT_TEMPERATURE)