From 0d3396ed64e5407987469162f5cb5ce561445f8a Mon Sep 17 00:00:00 2001 From: RogerSelwyn Date: Fri, 4 Sep 2020 21:31:06 +0100 Subject: [PATCH] Add mac address to sky_hub tracker (#39506) * Add mac address to Sky_Hub tracker * Update manifest.json * Update device_tracker.py * Update device_tracker.py * Update device_tracker.py * Apply suggestions from code review Co-authored-by: Chris Talkington --- .../components/sky_hub/device_tracker.py | 18 ++++++++++++++++-- homeassistant/components/sky_hub/manifest.json | 2 +- requirements_all.txt | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sky_hub/device_tracker.py b/homeassistant/components/sky_hub/device_tracker.py index b97331b6195..75241d78ed3 100644 --- a/homeassistant/components/sky_hub/device_tracker.py +++ b/homeassistant/components/sky_hub/device_tracker.py @@ -44,11 +44,25 @@ class SkyHubDeviceScanner(DeviceScanner): async def async_scan_devices(self): """Scan for new devices and return a list with found device IDs.""" await self._async_update_info() - return list(self.last_results) + return [device.mac for device in self.last_results] async def async_get_device_name(self, device): """Return the name of the given device.""" - return self.last_results.get(device) + name = next( + (result.name for result in self.last_results if result.mac == device), + None, + ) + return name + + async def async_get_extra_attributes(self, device): + """Get extra attributes of a device.""" + device = next( + (result for result in self.last_results if result.mac == device), None + ) + if device is None: + return {} + + return device.asdict() async def _async_update_info(self): """Ensure the information from the Sky Hub is up to date.""" diff --git a/homeassistant/components/sky_hub/manifest.json b/homeassistant/components/sky_hub/manifest.json index e663820a5ef..a0ef4bc8e0c 100644 --- a/homeassistant/components/sky_hub/manifest.json +++ b/homeassistant/components/sky_hub/manifest.json @@ -2,6 +2,6 @@ "domain": "sky_hub", "name": "Sky Hub", "documentation": "https://www.home-assistant.io/integrations/sky_hub", - "requirements": ["pyskyqhub==0.1.1"], + "requirements": ["pyskyqhub==0.1.2"], "codeowners": ["@rogerselwyn"] } diff --git a/requirements_all.txt b/requirements_all.txt index d3c6277d8c9..8c925a1c621 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1622,7 +1622,7 @@ pysher==1.0.1 pysignalclirestapi==0.3.4 # homeassistant.components.sky_hub -pyskyqhub==0.1.1 +pyskyqhub==0.1.2 # homeassistant.components.sma pysma==0.3.5