Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update_service callback for zeroconf listener #1112

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions miio/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,18 @@ def check_and_create_device(self, info, addr) -> Optional[Device]:
)
return None

def add_service(self, zeroconf, type, name):
info = zeroconf.get_service_info(type, name)
def add_service(self, zeroconf: "zeroconf.Zeroconf", type_: str, name: str) -> None:
"""Callback for discovery responses."""
info = zeroconf.get_service_info(type_, name)
addr = get_addr_from_info(info)

if addr not in self.found_devices:
dev = self.check_and_create_device(info, addr)
self.found_devices[addr] = dev
if dev is not None:
self.found_devices[addr] = dev

def update_service(self, zc: "zeroconf.Zeroconf", type_: str, name: str) -> None:
"""Callback for state updates, which we ignore for now."""


class Discovery:
Expand Down