Skip to content

Commit

Permalink
Offload mdns property decoding to zeroconf (#373)
Browse files Browse the repository at this point in the history
* Offload mdns property decoding to zeroconf

zeroconf has a built-in function to decode these

* lint
  • Loading branch information
bdraco authored Jul 27, 2024
1 parent d7ddbf8 commit d46c2c2
Show file tree
Hide file tree
Showing 3 changed files with 392 additions and 442 deletions.
8 changes: 2 additions & 6 deletions aiohomekit/zeroconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,9 @@ def from_service_info(cls, service: AsyncServiceInfo) -> HomeKitService:
"Invalid HomeKit Zeroconf record: Missing non-link-local or unspecified address"
)
address = valid_addresses[0]

props: dict[str, str] = {
k.decode("utf-8").lower(): v.decode("utf-8")
for (k, v) in service.properties.items()
if v is not None
props = {
k.lower(): v for k, v in service.decoded_properties.items() if v is not None
}

if "id" not in props:
raise ValueError("Invalid HomeKit Zeroconf record: Missing device ID")

Expand Down
Loading

0 comments on commit d46c2c2

Please sign in to comment.