Remove exception handling for AttributeError in wemo (#46674)
This commit is contained in:
parent
8c72cb6163
commit
94131df5e0
5 changed files with 8 additions and 6 deletions
|
@ -41,7 +41,7 @@ class WemoBinarySensor(WemoSubscriptionEntity, BinarySensorEntity):
|
||||||
if not self._available:
|
if not self._available:
|
||||||
_LOGGER.info("Reconnected to %s", self.name)
|
_LOGGER.info("Reconnected to %s", self.name)
|
||||||
self._available = True
|
self._available = True
|
||||||
except (AttributeError, ActionException) as err:
|
except ActionException as err:
|
||||||
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
||||||
self._available = False
|
self._available = False
|
||||||
self.wemo.reconnect_with_device()
|
self.wemo.reconnect_with_device()
|
||||||
|
|
|
@ -155,7 +155,7 @@ class WemoHumidifier(WemoSubscriptionEntity, FanEntity):
|
||||||
if not self._available:
|
if not self._available:
|
||||||
_LOGGER.info("Reconnected to %s", self.name)
|
_LOGGER.info("Reconnected to %s", self.name)
|
||||||
self._available = True
|
self._available = True
|
||||||
except (AttributeError, ActionException) as err:
|
except ActionException as err:
|
||||||
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
||||||
self._available = False
|
self._available = False
|
||||||
self.wemo.reconnect_with_device()
|
self.wemo.reconnect_with_device()
|
||||||
|
|
|
@ -191,7 +191,7 @@ class WemoLight(WemoEntity, LightEntity):
|
||||||
try:
|
try:
|
||||||
self._update_lights(no_throttle=force_update)
|
self._update_lights(no_throttle=force_update)
|
||||||
self._state = self.wemo.state
|
self._state = self.wemo.state
|
||||||
except (AttributeError, ActionException) as err:
|
except ActionException as err:
|
||||||
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
||||||
self._available = False
|
self._available = False
|
||||||
self.wemo.bridge.reconnect_with_device()
|
self.wemo.bridge.reconnect_with_device()
|
||||||
|
@ -238,7 +238,7 @@ class WemoDimmer(WemoSubscriptionEntity, LightEntity):
|
||||||
if not self._available:
|
if not self._available:
|
||||||
_LOGGER.info("Reconnected to %s", self.name)
|
_LOGGER.info("Reconnected to %s", self.name)
|
||||||
self._available = True
|
self._available = True
|
||||||
except (AttributeError, ActionException) as err:
|
except ActionException as err:
|
||||||
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
||||||
self._available = False
|
self._available = False
|
||||||
self.wemo.reconnect_with_device()
|
self.wemo.reconnect_with_device()
|
||||||
|
|
|
@ -177,7 +177,7 @@ class WemoSwitch(WemoSubscriptionEntity, SwitchEntity):
|
||||||
if not self._available:
|
if not self._available:
|
||||||
_LOGGER.info("Reconnected to %s", self.name)
|
_LOGGER.info("Reconnected to %s", self.name)
|
||||||
self._available = True
|
self._available = True
|
||||||
except (AttributeError, ActionException) as err:
|
except ActionException as err:
|
||||||
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
||||||
self._available = False
|
self._available = False
|
||||||
self.wemo.reconnect_with_device()
|
self.wemo.reconnect_with_device()
|
||||||
|
|
|
@ -6,6 +6,8 @@ import asyncio
|
||||||
import threading
|
import threading
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from pywemo.ouimeaux_device.api.service import ActionException
|
||||||
|
|
||||||
from homeassistant.components.homeassistant import (
|
from homeassistant.components.homeassistant import (
|
||||||
DOMAIN as HA_DOMAIN,
|
DOMAIN as HA_DOMAIN,
|
||||||
SERVICE_UPDATE_ENTITY,
|
SERVICE_UPDATE_ENTITY,
|
||||||
|
@ -127,7 +129,7 @@ async def test_async_locked_update_with_exception(
|
||||||
assert hass.states.get(wemo_entity.entity_id).state == STATE_OFF
|
assert hass.states.get(wemo_entity.entity_id).state == STATE_OFF
|
||||||
await async_setup_component(hass, HA_DOMAIN, {})
|
await async_setup_component(hass, HA_DOMAIN, {})
|
||||||
update_polling_method = update_polling_method or pywemo_device.get_state
|
update_polling_method = update_polling_method or pywemo_device.get_state
|
||||||
update_polling_method.side_effect = AttributeError
|
update_polling_method.side_effect = ActionException
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
HA_DOMAIN,
|
HA_DOMAIN,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue