From f6d69cc74cdf369b088ec56d347127b2a0279226 Mon Sep 17 00:00:00 2001 From: vlebourl Date: Tue, 18 Apr 2023 12:29:34 +0200 Subject: [PATCH] sourcery refactor. --- custom_components/vesync/humidifier.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/vesync/humidifier.py b/custom_components/vesync/humidifier.py index 9e0f5df..c9e854d 100644 --- a/custom_components/vesync/humidifier.py +++ b/custom_components/vesync/humidifier.py @@ -162,10 +162,10 @@ def set_humidity(self, humidity: int) -> None: raise ValueError( "{humidity} is not between {self.min_humidity} and {self.max_humidity} (inclusive)" ) - success = self.smarthumidifier.set_humidity(humidity) - if not success: + if self.smarthumidifier.set_humidity(humidity): + self.schedule_update_ha_state() + else: raise ValueError("An error occurred while setting humidity.") - self.schedule_update_ha_state() def set_mode(self, mode: str) -> None: """Set the mode of the device.""" @@ -173,10 +173,10 @@ def set_mode(self, mode: str) -> None: raise ValueError( "{mode} is not one of the valid available modes: {self.available_modes}" ) - success = self.smarthumidifier.set_humidity_mode(_get_vs_mode(mode)) - if not success: + if self.smarthumidifier.set_humidity_mode(_get_vs_mode(mode)): + self.schedule_update_ha_state() + else: raise ValueError("An error occurred while setting mode.") - self.schedule_update_ha_state() def turn_on( self,