This commit is contained in:
Feng Wang 2024-12-26 09:12:54 +08:00 committed by GitHub
commit f2c689f0ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 460 additions and 464 deletions

View File

@ -83,6 +83,9 @@ def randomize_int(value: int, ratio: float) -> int:
"""Randomize an integer value."""
return int(value * (1 - ratio + random.random()*2*ratio))
def randomize_float(value: float, ratio: float) -> float:
"""Randomize a float value."""
return value * (1 - ratio + random.random()*2*ratio)
class MIoTMatcher(MQTTMatcher):
"""MIoT Pub/Sub topic matcher."""

View File

@ -1089,7 +1089,7 @@ class MIoTClient:
handler=self.__on_lan_device_state_changed)
for did, info in (
await self._miot_lan.get_dev_list_async()).items():
self.__on_lan_device_state_changed(
await self.__on_lan_device_state_changed(
did=did, state=info, ctx=None)
_LOGGER.info('lan device list, %s', self._device_list_lan)
self._miot_lan.update_devices(devices={

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ import socket
from dataclasses import dataclass
from enum import Enum, auto
import subprocess
from typing import Callable, Optional
from typing import Callable, Coroutine, Optional
import psutil
import ipaddress
@ -97,7 +97,7 @@ class MIoTNetwork:
_sub_list_network_status: dict[str, Callable[[bool], asyncio.Future]]
_sub_list_network_info: dict[str, Callable[[
InterfaceStatus, NetworkInfo], asyncio.Future]]
InterfaceStatus, NetworkInfo], Coroutine]]
_ping_address_priority: int
@ -155,7 +155,7 @@ class MIoTNetwork:
def sub_network_info(
self, key: str,
handler: Callable[[InterfaceStatus, NetworkInfo], asyncio.Future]
handler: Callable[[InterfaceStatus, NetworkInfo], Coroutine]
) -> None:
self._sub_list_network_info[key] = handler