mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Bump aiodhcpwatcher to 1.0.0 (#113469)
This commit is contained in:
parent
4fb127e5af
commit
e293afe46e
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
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 the passive classes we need to start listening
|
||||||
# for state changes and connect the dispatchers before
|
# for state changes and connect the dispatchers before
|
||||||
# everything else starts up or we will miss events
|
# everything else starts up or we will miss events
|
||||||
for passive_cls in (DeviceTrackerRegisteredWatcher, DeviceTrackerWatcher):
|
device_watcher = DeviceTrackerWatcher(hass, address_data, integration_matchers)
|
||||||
passive_watcher = passive_cls(hass, address_data, integration_matchers)
|
device_watcher.async_start()
|
||||||
passive_watcher.async_start()
|
watchers.append(device_watcher)
|
||||||
watchers.append(passive_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:
|
async def _async_initialize(event: Event) -> None:
|
||||||
await aiodhcpwatcher.async_init()
|
await aiodhcpwatcher.async_init()
|
||||||
|
|
||||||
for active_cls in (DHCPWatcher, NetworkWatcher):
|
network_watcher = NetworkWatcher(hass, address_data, integration_matchers)
|
||||||
active_watcher = active_cls(hass, address_data, integration_matchers)
|
network_watcher.async_start()
|
||||||
active_watcher.async_start()
|
watchers.append(network_watcher)
|
||||||
watchers.append(active_watcher)
|
|
||||||
|
dhcp_watcher = DHCPWatcher(hass, address_data, integration_matchers)
|
||||||
|
await dhcp_watcher.async_start()
|
||||||
|
watchers.append(dhcp_watcher)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_stop(event: Event) -> None:
|
def _async_stop(event: Event) -> None:
|
||||||
@ -156,7 +163,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class WatcherBase(ABC):
|
class WatcherBase:
|
||||||
"""Base class for dhcp and device tracker watching."""
|
"""Base class for dhcp and device tracker watching."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -180,11 +187,6 @@ class WatcherBase(ABC):
|
|||||||
self._unsub()
|
self._unsub()
|
||||||
self._unsub = None
|
self._unsub = None
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
@callback
|
|
||||||
def async_start(self) -> None:
|
|
||||||
"""Start the watcher."""
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_process_client(
|
def async_process_client(
|
||||||
self, ip_address: str, hostname: str, unformatted_mac_address: str
|
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
|
response.ip_address, response.hostname, response.mac_address
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
async def async_start(self) -> None:
|
||||||
def async_start(self) -> None:
|
|
||||||
"""Start watching for dhcp packets."""
|
"""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)
|
@lru_cache(maxsize=4096, typed=True)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
],
|
],
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"aiodhcpwatcher==0.8.2",
|
"aiodhcpwatcher==1.0.0",
|
||||||
"aiodiscover==2.0.0",
|
"aiodiscover==2.0.0",
|
||||||
"cached_ipaddress==0.3.0"
|
"cached_ipaddress==0.3.0"
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Automatically generated by gen_requirements_all.py, do not edit
|
# Automatically generated by gen_requirements_all.py, do not edit
|
||||||
|
|
||||||
aiodhcpwatcher==0.8.2
|
aiodhcpwatcher==1.0.0
|
||||||
aiodiscover==2.0.0
|
aiodiscover==2.0.0
|
||||||
aiohttp-fast-url-dispatcher==0.3.0
|
aiohttp-fast-url-dispatcher==0.3.0
|
||||||
aiohttp-zlib-ng==0.3.1
|
aiohttp-zlib-ng==0.3.1
|
||||||
|
@ -218,7 +218,7 @@ aiobotocore==2.9.1
|
|||||||
aiocomelit==0.9.0
|
aiocomelit==0.9.0
|
||||||
|
|
||||||
# homeassistant.components.dhcp
|
# homeassistant.components.dhcp
|
||||||
aiodhcpwatcher==0.8.2
|
aiodhcpwatcher==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.dhcp
|
# homeassistant.components.dhcp
|
||||||
aiodiscover==2.0.0
|
aiodiscover==2.0.0
|
||||||
|
@ -197,7 +197,7 @@ aiobotocore==2.9.1
|
|||||||
aiocomelit==0.9.0
|
aiocomelit==0.9.0
|
||||||
|
|
||||||
# homeassistant.components.dhcp
|
# homeassistant.components.dhcp
|
||||||
aiodhcpwatcher==0.8.2
|
aiodhcpwatcher==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.dhcp
|
# homeassistant.components.dhcp
|
||||||
aiodiscover==2.0.0
|
aiodiscover==2.0.0
|
||||||
|
@ -145,8 +145,8 @@ async def _async_get_handle_dhcp_packet(
|
|||||||
{},
|
{},
|
||||||
integration_matchers,
|
integration_matchers,
|
||||||
)
|
)
|
||||||
with patch("aiodhcpwatcher.start"):
|
with patch("aiodhcpwatcher.async_start"):
|
||||||
dhcp_watcher.async_start()
|
await dhcp_watcher.async_start()
|
||||||
|
|
||||||
def _async_handle_dhcp_request(request: aiodhcpwatcher.DHCPRequest) -> None:
|
def _async_handle_dhcp_request(request: aiodhcpwatcher.DHCPRequest) -> None:
|
||||||
dhcp_watcher._async_process_dhcp_request(request)
|
dhcp_watcher._async_process_dhcp_request(request)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user