Use dataclass properties in yeelight ()

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-03 18:20:58 +01:00 committed by GitHub
parent adf2fa5664
commit a6cd3e2a02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -174,17 +174,18 @@ class YeelightScanner:
# of another discovery # of another discovery
async_call_later(self._hass, 1, _async_start_flow) 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.""" """Process a discovery."""
_LOGGER.debug("Discovered via SSDP: %s", response) _LOGGER.debug("Discovered via SSDP: %s", response)
unique_id = response["id"] headers = response.ssdp_headers
host = urlparse(response["location"]).hostname unique_id = headers["id"]
host = urlparse(headers["location"]).hostname
current_entry = self._unique_id_capabilities.get(unique_id) current_entry = self._unique_id_capabilities.get(unique_id)
# Make sure we handle ip changes # Make sure we handle ip changes
if not current_entry or host != urlparse(current_entry["location"]).hostname: if not current_entry or host != urlparse(current_entry["location"]).hostname:
_LOGGER.debug("Yeelight discovered with %s", response) _LOGGER.debug("Yeelight discovered with %s", headers)
self._async_discovered_by_ssdp(response) self._async_discovered_by_ssdp(headers)
self._host_capabilities[host] = response self._host_capabilities[host] = headers
self._unique_id_capabilities[unique_id] = response self._unique_id_capabilities[unique_id] = headers
for event in self._host_discovered_events.get(host, []): for event in self._host_discovered_events.get(host, []):
event.set() event.set()