From 12d4ddca719512372209957d3fe63c3b7ea4a255 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Fri, 4 Oct 2019 15:31:23 +0200 Subject: [PATCH] Fix attr update (#11) * Fix issue with new attribute version * Fix style --- connect_box/__init__.py | 9 ++++----- connect_box/data.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/connect_box/__init__.py b/connect_box/__init__.py index f172e70..593d84b 100644 --- a/connect_box/__init__.py +++ b/connect_box/__init__.py @@ -50,8 +50,9 @@ async def async_get_devices(self) -> List[Device]: if self.token is None: await self.async_initialize_token() - raw = await self._async_ws_function(CMD_DEVICES) self.devices.clear() + raw = await self._async_ws_function(CMD_DEVICES) + try: xml_root = element_tree.fromstring(raw) mac_adresses: List[str] = [mac.text for mac in xml_root.iter("MACAddr")] @@ -71,15 +72,14 @@ async def async_get_devices(self) -> List[Device]: async def async_get_downstream(self): """Get the current downstream cable modem state.""" - if self.token is None: await self.async_initialize_token() + self.ds_channels.clear() raw = await self._async_ws_function(CMD_DOWNSTREAM) try: xml_root = element_tree.fromstring(raw) - self.ds_channels.clear() for downstream in xml_root.iter("downstream"): self.ds_channels.append( DownstreamChannel( @@ -102,15 +102,14 @@ async def async_get_downstream(self): async def async_get_upstream(self): """Get the current upstream cable modem state.""" - if self.token is None: await self.async_initialize_token() + self.us_channels.clear() raw = await self._async_ws_function(CMD_UPSTREAM) try: xml_root = element_tree.fromstring(raw) - self.us_channels.clear() for upstream in xml_root.iter("upstream"): self.us_channels.append( UpstreamChannel( diff --git a/connect_box/data.py b/connect_box/data.py index 2101f1e..c21658c 100644 --- a/connect_box/data.py +++ b/connect_box/data.py @@ -11,7 +11,7 @@ class Device: mac: str = attr.ib() hostname: str = attr.ib(cmp=False) - ip: Union[IPv4Address, IPv6Address] = attr.ib(cmp=False, convert=convert_ip) + ip: Union[IPv4Address, IPv6Address] = attr.ib(cmp=False, converter=convert_ip) @attr.s