From a977f398ae244d53d85fdafeda8dce7c53d6d608 Mon Sep 17 00:00:00 2001 From: akasma74 Date: Fri, 22 Nov 2019 20:27:40 +0000 Subject: [PATCH] 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. --- homeassistant/components/generic_thermostat/climate.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/generic_thermostat/climate.py b/homeassistant/components/generic_thermostat/climate.py index b765dbbfda4..5cb4c21c577 100644 --- a/homeassistant/components/generic_thermostat/climate.py +++ b/homeassistant/components/generic_thermostat/climate.py @@ -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."""