Use dataclass properties in yeelight ()

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/60927/head
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
1 changed files with 8 additions and 7 deletions
homeassistant/components/yeelight

View File

@ -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()