From 2cb9783cf5591851b146b8d378ad8fe1463fe9bb Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sun, 1 May 2022 19:00:58 +0200 Subject: [PATCH] Small cleanup Sensibo (#71149) * Cleanup * fix temp * Modify set_temp * Apply suggestions from code review Co-authored-by: Shay Levy --- homeassistant/components/sensibo/__init__.py | 5 ++--- homeassistant/components/sensibo/climate.py | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/sensibo/__init__.py b/homeassistant/components/sensibo/__init__.py index ab8e4e85d39..dc02e9ee686 100644 --- a/homeassistant/components/sensibo/__init__.py +++ b/homeassistant/components/sensibo/__init__.py @@ -26,12 +26,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload Sensibo config entry.""" - if await hass.config_entries.async_unload_platforms(entry, PLATFORMS): + if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS): del hass.data[DOMAIN][entry.entry_id] if not hass.data[DOMAIN]: del hass.data[DOMAIN] - return True - return False + return unload_ok async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index 907105b5384..c1e690cd28a 100644 --- a/homeassistant/components/sensibo/climate.py +++ b/homeassistant/components/sensibo/climate.py @@ -178,7 +178,7 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity): ) if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: - return + raise ValueError("No target temperature provided") if temperature == self.target_temperature: return @@ -192,7 +192,9 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity): temperature = self.device_data.temp_list[0] else: - return + raise ValueError( + f"Target temperature has to be one off {str(self.device_data.temp_list)}" + ) await self._async_set_ac_state_property("targetTemperature", int(temperature))