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
1 changed files with 3 additions and 7 deletions
|
@ -298,16 +298,12 @@ class GenericThermostat(ClimateDevice, RestoreEntity):
|
|||
@property
|
||||
def preset_mode(self):
|
||||
"""Return the current preset mode, e.g., home, away, temp."""
|
||||
if self._is_away:
|
||||
return PRESET_AWAY
|
||||
return None
|
||||
return PRESET_AWAY if self._is_away else PRESET_NONE
|
||||
|
||||
@property
|
||||
def preset_modes(self):
|
||||
"""Return a list of available preset modes."""
|
||||
if self._away_temp:
|
||||
return [PRESET_NONE, PRESET_AWAY]
|
||||
return None
|
||||
"""Return a list of available preset modes or PRESET_NONE if _away_temp is undefined."""
|
||||
return [PRESET_NONE, PRESET_AWAY] if self._away_temp else PRESET_NONE
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode):
|
||||
"""Set hvac mode."""
|
||||
|
|
Loading…
Add table
Reference in a new issue