Use async zeroconf registration functions (#50168)
This commit is contained in:
parent
e616583bad
commit
909a20b36d
4 changed files with 44 additions and 18 deletions
|
@ -1,6 +1,10 @@
|
|||
"""Models for Zeroconf."""
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
from zeroconf import DNSPointer, DNSRecord, ServiceBrowser, Zeroconf
|
||||
from zeroconf.asyncio import AsyncZeroconf
|
||||
|
||||
|
||||
class HaZeroconf(Zeroconf):
|
||||
|
@ -12,6 +16,20 @@ class HaZeroconf(Zeroconf):
|
|||
ha_close = Zeroconf.close
|
||||
|
||||
|
||||
class HaAsyncZeroconf(AsyncZeroconf):
|
||||
"""Home Assistant version of AsyncZeroconf."""
|
||||
|
||||
def __init__( # pylint: disable=super-init-not-called
|
||||
self, *args: Any, **kwargs: Any
|
||||
) -> None:
|
||||
"""Wrap AsyncZeroconf."""
|
||||
self.zeroconf = HaZeroconf(*args, **kwargs)
|
||||
self.loop = asyncio.get_running_loop()
|
||||
|
||||
async def async_close(self) -> None:
|
||||
"""Fake method to avoid integrations closing it."""
|
||||
|
||||
|
||||
class HaServiceBrowser(ServiceBrowser):
|
||||
"""ServiceBrowser that only consumes DNSPointer records."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue