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:
akasma74 2019-11-22 20:27:40 +00:00 committed by Franck Nijhof
parent d92f48646a
commit a977f398ae

View file

@ -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."""