mirror of
https://github.com/esphome/esphome.git
synced 2025-04-19 09:10:29 +01:00
python formating
This commit is contained in:
parent
4e8deb8232
commit
6adc323f66
@ -50,7 +50,6 @@ from esphome.util import (
|
||||
run_external_process,
|
||||
safe_print,
|
||||
)
|
||||
|
||||
from esphome.zeroconf import get_mac_suffix_nodes
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
import time
|
||||
import logging
|
||||
from typing import Callable, Optional
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
from zeroconf import IPVersion, ServiceInfo, ServiceStateChange, Zeroconf
|
||||
from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconf
|
||||
@ -201,24 +201,29 @@ class AsyncEsphomeZeroconf(AsyncZeroconf):
|
||||
return addresses
|
||||
return None
|
||||
|
||||
|
||||
NODE_SCAN_TIME_SEC = 2
|
||||
|
||||
|
||||
class NodeScanner:
|
||||
def __init__(self, node_raw_name: str) -> None:
|
||||
self.node_raw_name = node_raw_name
|
||||
self.aiobrowser: Optional[AsyncServiceBrowser] = None
|
||||
self.aiozc: Optional[AsyncZeroconf] = None
|
||||
self.aiobrowser: AsyncServiceBrowser | None = None
|
||||
self.aiozc: AsyncZeroconf | None = None
|
||||
self.found_nodes = []
|
||||
|
||||
def async_on_service_state_change(self,
|
||||
zeroconf: Zeroconf, service_type: str, name: str, state_change: ServiceStateChange
|
||||
def async_on_service_state_change(
|
||||
self,
|
||||
zeroconf: Zeroconf,
|
||||
service_type: str,
|
||||
name: str,
|
||||
state_change: ServiceStateChange,
|
||||
) -> None:
|
||||
if state_change is not ServiceStateChange.Added:
|
||||
return
|
||||
if name.startswith(self.node_raw_name):
|
||||
self.found_nodes.append(name.split(".")[0] + ".local")
|
||||
|
||||
|
||||
async def async_run(self) -> None:
|
||||
self.aiozc = AsyncZeroconf(ip_version=IPVersion.V4Only)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user