From a6cd3e2a02ca3df19edd7b935da5f393c59a3b65 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 3 Dec 2021 18:20:58 +0100 Subject: [PATCH] Use dataclass properties in yeelight (#60912) Co-authored-by: epenet --- homeassistant/components/yeelight/scanner.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/yeelight/scanner.py b/homeassistant/components/yeelight/scanner.py index 4b372df3744..648168ff84a 100644 --- a/homeassistant/components/yeelight/scanner.py +++ b/homeassistant/components/yeelight/scanner.py @@ -174,17 +174,18 @@ class YeelightScanner: # of another discovery async_call_later(self._hass, 1, _async_start_flow) - async def _async_process_entry(self, response): + async def _async_process_entry(self, response: ssdp.SsdpServiceInfo): """Process a discovery.""" _LOGGER.debug("Discovered via SSDP: %s", response) - unique_id = response["id"] - host = urlparse(response["location"]).hostname + headers = response.ssdp_headers + unique_id = headers["id"] + host = urlparse(headers["location"]).hostname current_entry = self._unique_id_capabilities.get(unique_id) # Make sure we handle ip changes if not current_entry or host != urlparse(current_entry["location"]).hostname: - _LOGGER.debug("Yeelight discovered with %s", response) - self._async_discovered_by_ssdp(response) - self._host_capabilities[host] = response - self._unique_id_capabilities[unique_id] = response + _LOGGER.debug("Yeelight discovered with %s", headers) + self._async_discovered_by_ssdp(headers) + self._host_capabilities[host] = headers + self._unique_id_capabilities[unique_id] = headers for event in self._host_discovered_events.get(host, []): event.set()