diff --git a/CODEOWNERS b/CODEOWNERS index e63ab433fdd..89244ccd809 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -457,7 +457,6 @@ homeassistant/components/watson_tts/* @rutkai homeassistant/components/weather/* @fabaff homeassistant/components/webostv/* @bendavid homeassistant/components/websocket_api/* @home-assistant/core -homeassistant/components/wemo/* @sqldiablo homeassistant/components/wiffi/* @mampfes homeassistant/components/withings/* @vangorra homeassistant/components/wled/* @frenck diff --git a/homeassistant/components/wemo/fan.py b/homeassistant/components/wemo/fan.py index f040a9f3845..f2cb46fa32c 100644 --- a/homeassistant/components/wemo/fan.py +++ b/homeassistant/components/wemo/fan.py @@ -304,6 +304,8 @@ class WemoHumidifier(FanEntity): else: self.set_speed(speed) + self.schedule_update_ha_state() + def turn_off(self, **kwargs) -> None: """Turn the switch off.""" try: @@ -312,6 +314,8 @@ class WemoHumidifier(FanEntity): _LOGGER.warning("Error while turning off device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + def set_speed(self, speed: str) -> None: """Set the fan_mode of the Humidifier.""" try: @@ -322,6 +326,8 @@ class WemoHumidifier(FanEntity): ) self._available = False + self.schedule_update_ha_state() + def set_humidity(self, humidity: float) -> None: """Set the target humidity level for the Humidifier.""" if humidity < 50: @@ -343,6 +349,8 @@ class WemoHumidifier(FanEntity): ) self._available = False + self.schedule_update_ha_state() + def reset_filter_life(self) -> None: """Reset the filter life to 100%.""" try: @@ -352,3 +360,5 @@ class WemoHumidifier(FanEntity): "Error while resetting filter life on device: %s (%s)", self.name, err ) self._available = False + + self.schedule_update_ha_state() diff --git a/homeassistant/components/wemo/light.py b/homeassistant/components/wemo/light.py index 2a05d42f1f7..6aac2be6dda 100644 --- a/homeassistant/components/wemo/light.py +++ b/homeassistant/components/wemo/light.py @@ -32,6 +32,10 @@ SUPPORT_WEMO = ( SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR | SUPPORT_TRANSITION ) +# The WEMO_ constants below come from pywemo itself +WEMO_ON = 1 +WEMO_OFF = 0 + async def async_setup_entry(hass, config_entry, async_add_entities): """Set up WeMo lights.""" @@ -175,21 +179,27 @@ class WemoLight(LightEntity): if color_temp is not None: self.wemo.set_temperature(mireds=color_temp, transition=transition_time) - self.wemo.turn_on(**turn_on_kwargs) + if self.wemo.turn_on(**turn_on_kwargs): + self._state["onoff"] = WEMO_ON except ActionException as err: _LOGGER.warning("Error while turning on device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + def turn_off(self, **kwargs): """Turn the light off.""" transition_time = int(kwargs.get(ATTR_TRANSITION, 0)) try: - self.wemo.turn_off(transition=transition_time) + if self.wemo.turn_off(transition=transition_time): + self._state["onoff"] = WEMO_OFF except ActionException as err: _LOGGER.warning("Error while turning off device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + def _update(self, force_update=True): """Synchronize state with bridge.""" try: @@ -200,7 +210,7 @@ class WemoLight(LightEntity): self._available = False self.wemo.reconnect_with_device() else: - self._is_on = self._state.get("onoff") != 0 + self._is_on = self._state.get("onoff") != WEMO_OFF self._brightness = self._state.get("level", 255) self._color_temp = self._state.get("temperature_mireds") self._available = True @@ -355,20 +365,27 @@ class WemoDimmer(LightEntity): brightness = 255 try: - self.wemo.on() + if self.wemo.on(): + self._state = WEMO_ON + self.wemo.set_brightness(brightness) except ActionException as err: _LOGGER.warning("Error while turning on device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + def turn_off(self, **kwargs): """Turn the dimmer off.""" try: - self.wemo.off() + if self.wemo.off(): + self._state = WEMO_OFF except ActionException as err: _LOGGER.warning("Error while turning on device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + @property def available(self): """Return if dimmer is available.""" diff --git a/homeassistant/components/wemo/manifest.json b/homeassistant/components/wemo/manifest.json index 96efb140cee..e08e82b3269 100644 --- a/homeassistant/components/wemo/manifest.json +++ b/homeassistant/components/wemo/manifest.json @@ -12,5 +12,5 @@ "homekit": { "models": ["Wemo"] }, - "codeowners": ["@sqldiablo"] + "codeowners": [] } diff --git a/homeassistant/components/wemo/switch.py b/homeassistant/components/wemo/switch.py index 836ddf0730f..7cc88f552bf 100644 --- a/homeassistant/components/wemo/switch.py +++ b/homeassistant/components/wemo/switch.py @@ -18,6 +18,7 @@ PARALLEL_UPDATES = 0 _LOGGER = logging.getLogger(__name__) +# The WEMO_ constants below come from pywemo itself ATTR_SENSOR_STATE = "sensor_state" ATTR_SWITCH_MODE = "switch_mode" ATTR_CURRENT_STATE_DETAIL = "state_detail" @@ -191,19 +192,25 @@ class WemoSwitch(SwitchEntity): def turn_on(self, **kwargs): """Turn the switch on.""" try: - self.wemo.on() + if self.wemo.on(): + self._state = WEMO_ON except ActionException as err: _LOGGER.warning("Error while turning on device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + def turn_off(self, **kwargs): """Turn the switch off.""" try: - self.wemo.off() + if self.wemo.off(): + self._state = WEMO_OFF except ActionException as err: _LOGGER.warning("Error while turning off device %s (%s)", self.name, err) self._available = False + self.schedule_update_ha_state() + async def async_added_to_hass(self): """Wemo switch added to Home Assistant.""" # Define inside async context so we know our event loop