Skip to content

Commit 2a52f24

Browse files
Correct #250
This issue comes from a simple cause but a bug in HA made it look very weird. Cause: accessing attributes before having them defined. Fix: simply define the attribute in constructor Fix #250
1 parent 7af92d0 commit 2a52f24

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

custom_components/aquarea/climate.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ def __init__(
165165
# we only display heater by default
166166
self._attr_entity_registry_enabled_default = self.heater
167167

168+
# set default values so that attribute is always defined
169+
self._attr_min_temp = self.UNDEFINED_VALUE
170+
self._attr_max_temp = self.UNDEFINED_VALUE
171+
172+
UNDEFINED_VALUE = -42
173+
168174
async def async_turn_off(self) -> None:
169175
await self.async_set_hvac_mode(HVACMode.OFF)
170176

@@ -359,7 +365,7 @@ def target_temperature_message_received(message):
359365
f"{self._climate_type()} Received target temperature for {self.zone_id}: {self._attr_target_temperature}"
360366
)
361367
if not self._mode_guessed:
362-
if self._attr_min_temp != None and self._attr_max_temp != None:
368+
if self._attr_min_temp != self.UNDEFINED_VALUE and self._attr_max_temp != self.UNDEFINED_VALUE:
363369
if self._attr_target_temperature < self._attr_min_temp or self._attr_target_temperature > self._attr_max_temp:
364370
# when reaching that point, maybe we should set a wider range to avoid blocking user?
365371
_LOGGER.warn(f"{self._climate_type()} Target temperature is not within expected range, this is suspicious. {self._attr_target_temperature} should be within [{self._attr_min_temp},{self._attr_max_temp}]")

0 commit comments

Comments
 (0)