Bump PyWeMo version to 0.4.43 (#35693)
* PyWeMo version bump to 0.4.43 Changes necessary to safely upgrade to pyWeMo 0.4.43. This includes catching ActionExceptions that may be thrown by pyWeMo when it is unable to interact with a physical device. * Black formatting fix * Fix isort issues * Code review changes * More code review fixes * Linting fix * Undo dict.get change * Change a couple instances of dict[key] to dict.get
This commit is contained in:
1 parent
b42a197293
commit
5104b79b4b
6 files changed
+144
-62
No files matched your search
@@ -3,6 +3,7 @@ import asyncio
|
||||
import logging
|
||||
|
||||
import async_timeout
|
||||
from pywemo.ouimeaux_device.api.service import ActionException
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@@ -40,7 +41,7 @@ class WemoBinarySensor(BinarySensorEntity):
|
||||
self._update_lock = None
|
||||
self._model_name = self.wemo.model_name
|
||||
self._name = self.wemo.name
|
||||
self._serialnumber = self.wemo.serialnumber
|
||||
self._serial_number = self.wemo.serialnumber
|
||||
|
||||
def _subscription_callback(self, _device, _type, _params):
|
||||
"""Update the state by the Wemo sensor."""
|
||||
@@ -98,14 +99,15 @@ class WemoBinarySensor(BinarySensorEntity):
|
||||
if not self._available:
|
||||
_LOGGER.info("Reconnected to %s", self.name)
|
||||
self._available = True
|
||||
except AttributeError as err:
|
||||
except (AttributeError, ActionException) as err:
|
||||
_LOGGER.warning("Could not update status for %s (%s)", self.name, err)
|
||||
self._available = False
|
||||
self.wemo.reconnect_with_device()
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the id of this WeMo sensor."""
|
||||
return self._serialnumber
|
||||
return self._serial_number
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -126,8 +128,8 @@ class WemoBinarySensor(BinarySensorEntity):
|
||||
def device_info(self):
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"name": self.wemo.name,
|
||||
"identifiers": {(WEMO_DOMAIN, self.wemo.serialnumber)},
|
||||
"model": self.wemo.model_name,
|
||||
"name": self._name,
|
||||
"identifiers": {(WEMO_DOMAIN, self._serial_number)},
|
||||
"model": self._model_name,
|
||||
"manufacturer": "Belkin",
|
||||
}
|
||||
Reference in new issue
Block a user