Bump aiodhcpwatcher to 1.0.0 (#113469)

This commit is contained in:
J. Nick Koston 2024-03-14 14:16:19 -10:00 committed by GitHub
parent 4fb127e5af
commit e293afe46e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 24 deletions

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from abc import ABC, abstractmethod
import asyncio
from collections.abc import Callable
from dataclasses import dataclass
@ -132,18 +131,26 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
# For the passive classes we need to start listening
# for state changes and connect the dispatchers before
# everything else starts up or we will miss events
for passive_cls in (DeviceTrackerRegisteredWatcher, DeviceTrackerWatcher):
passive_watcher = passive_cls(hass, address_data, integration_matchers)
passive_watcher.async_start()
watchers.append(passive_watcher)
device_watcher = DeviceTrackerWatcher(hass, address_data, integration_matchers)
device_watcher.async_start()
watchers.append(device_watcher)
device_tracker_registered_watcher = DeviceTrackerRegisteredWatcher(
hass, address_data, integration_matchers
)
device_tracker_registered_watcher.async_start()
watchers.append(device_tracker_registered_watcher)
async def _async_initialize(event: Event) -> None:
await aiodhcpwatcher.async_init()
for active_cls in (DHCPWatcher, NetworkWatcher):
active_watcher = active_cls(hass, address_data, integration_matchers)
active_watcher.async_start()
watchers.append(active_watcher)
network_watcher = NetworkWatcher(hass, address_data, integration_matchers)
network_watcher.async_start()
watchers.append(network_watcher)
dhcp_watcher = DHCPWatcher(hass, address_data, integration_matchers)
await dhcp_watcher.async_start()
watchers.append(dhcp_watcher)
@callback
def _async_stop(event: Event) -> None:
@ -156,7 +163,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
class WatcherBase(ABC):
class WatcherBase:
"""Base class for dhcp and device tracker watching."""
def __init__(
@ -180,11 +187,6 @@ class WatcherBase(ABC):
self._unsub()
self._unsub = None
@abstractmethod
@callback
def async_start(self) -> None:
"""Start the watcher."""
@callback
def async_process_client(
self, ip_address: str, hostname: str, unformatted_mac_address: str
@ -403,10 +405,9 @@ class DHCPWatcher(WatcherBase):
response.ip_address, response.hostname, response.mac_address
)
@callback
def async_start(self) -> None:
async def async_start(self) -> None:
"""Start watching for dhcp packets."""
self._unsub = aiodhcpwatcher.start(self._async_process_dhcp_request)
self._unsub = await aiodhcpwatcher.async_start(self._async_process_dhcp_request)
@lru_cache(maxsize=4096, typed=True)

View File

@ -14,7 +14,7 @@
],
"quality_scale": "internal",
"requirements": [
"aiodhcpwatcher==0.8.2",
"aiodhcpwatcher==1.0.0",
"aiodiscover==2.0.0",
"cached_ipaddress==0.3.0"
]

View File

@ -1,6 +1,6 @@
# Automatically generated by gen_requirements_all.py, do not edit
aiodhcpwatcher==0.8.2
aiodhcpwatcher==1.0.0
aiodiscover==2.0.0
aiohttp-fast-url-dispatcher==0.3.0
aiohttp-zlib-ng==0.3.1

View File

@ -218,7 +218,7 @@ aiobotocore==2.9.1
aiocomelit==0.9.0
# homeassistant.components.dhcp
aiodhcpwatcher==0.8.2
aiodhcpwatcher==1.0.0
# homeassistant.components.dhcp
aiodiscover==2.0.0

View File

@ -197,7 +197,7 @@ aiobotocore==2.9.1
aiocomelit==0.9.0
# homeassistant.components.dhcp
aiodhcpwatcher==0.8.2
aiodhcpwatcher==1.0.0
# homeassistant.components.dhcp
aiodiscover==2.0.0

View File

@ -145,8 +145,8 @@ async def _async_get_handle_dhcp_packet(
{},
integration_matchers,
)
with patch("aiodhcpwatcher.start"):
dhcp_watcher.async_start()
with patch("aiodhcpwatcher.async_start"):
await dhcp_watcher.async_start()
def _async_handle_dhcp_request(request: aiodhcpwatcher.DHCPRequest) -> None:
dhcp_watcher._async_process_dhcp_request(request)