mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix return values of preset_mode(s) properties (#27751)
It is incorrect to return None as a result of proprety call because in such a case state_attr call will return None as well, which means "Unknown attribute". Instead for preset_mode(s) PRESET_NONE constant should be used for consistency.
This commit is contained in:
parent
d92f48646a
commit
a977f398ae
@ -298,16 +298,12 @@ class GenericThermostat(ClimateDevice, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def preset_mode(self):
|
def preset_mode(self):
|
||||||
"""Return the current preset mode, e.g., home, away, temp."""
|
"""Return the current preset mode, e.g., home, away, temp."""
|
||||||
if self._is_away:
|
return PRESET_AWAY if self._is_away else PRESET_NONE
|
||||||
return PRESET_AWAY
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_modes(self):
|
def preset_modes(self):
|
||||||
"""Return a list of available preset modes."""
|
"""Return a list of available preset modes or PRESET_NONE if _away_temp is undefined."""
|
||||||
if self._away_temp:
|
return [PRESET_NONE, PRESET_AWAY] if self._away_temp else PRESET_NONE
|
||||||
return [PRESET_NONE, PRESET_AWAY]
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode):
|
async def async_set_hvac_mode(self, hvac_mode):
|
||||||
"""Set hvac mode."""
|
"""Set hvac mode."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user