Use dataclass properties in homekit_controller discovery (#60626)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-11-30 16:06:18 +01:00 committed by GitHub
parent 3f22905709
commit 0d24862a28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -208,8 +208,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
# homekit_python has code to do this, but not in a form we can
# easily use, so do the bare minimum ourselves here instead.
properties = {
key.lower(): value
for (key, value) in discovery_info[zeroconf.ATTR_PROPERTIES].items()
key.lower(): value for (key, value) in discovery_info.properties.items()
}
if zeroconf.ATTR_PROPERTIES_ID not in properties:
@ -225,7 +224,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
# It changes if a device is factory reset.
hkid = properties[zeroconf.ATTR_PROPERTIES_ID]
model = properties["md"]
name = discovery_info[zeroconf.ATTR_NAME].replace("._hap._tcp.local.", "")
name = discovery_info.name.replace("._hap._tcp.local.", "")
status_flags = int(properties["sf"])
paired = not status_flags & 0x01
@ -243,8 +242,8 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
# Set unique-id and error out if it's already configured
existing_entry = await self.async_set_unique_id(normalize_hkid(hkid))
updated_ip_port = {
"AccessoryIP": discovery_info[zeroconf.ATTR_HOST],
"AccessoryPort": discovery_info[zeroconf.ATTR_PORT],
"AccessoryIP": discovery_info.host,
"AccessoryPort": discovery_info.port,
}
# If the device is already paired and known to us we should monitor c#