mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-16 23:00:43 +08:00
Compare commits
13 Commits
ab6c146eee
...
6535dda18c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6535dda18c | ||
|
|
f614181755 | ||
|
|
fb46bc6b19 | ||
|
|
d3c39f38e1 | ||
|
|
d13a6bfb11 | ||
|
|
463216d866 | ||
|
|
30e0433aee | ||
|
|
0872bf4f69 | ||
|
|
3f77738b90 | ||
|
|
f288a951b9 | ||
|
|
569e1512e3 | ||
|
|
794505f082 | ||
|
|
faa13c53e8 |
@ -83,6 +83,9 @@ def randomize_int(value: int, ratio: float) -> int:
|
|||||||
"""Randomize an integer value."""
|
"""Randomize an integer value."""
|
||||||
return int(value * (1 - ratio + random.random()*2*ratio))
|
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):
|
class MIoTMatcher(MQTTMatcher):
|
||||||
"""MIoT Pub/Sub topic matcher."""
|
"""MIoT Pub/Sub topic matcher."""
|
||||||
|
|||||||
@ -1069,7 +1069,7 @@ class MIoTClient:
|
|||||||
handler=self.__on_lan_device_state_changed)
|
handler=self.__on_lan_device_state_changed)
|
||||||
for did, info in (
|
for did, info in (
|
||||||
await self._miot_lan.get_dev_list_async()).items():
|
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)
|
did=did, state=info, ctx=None)
|
||||||
_LOGGER.info('lan device list, %s', self._device_list_lan)
|
_LOGGER.info('lan device list, %s', self._device_list_lan)
|
||||||
self._miot_lan.update_devices(devices={
|
self._miot_lan.update_devices(devices={
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ import base64
|
|||||||
import binascii
|
import binascii
|
||||||
import copy
|
import copy
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional, Coroutine
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from zeroconf import (
|
from zeroconf import (
|
||||||
@ -151,7 +151,7 @@ class MipsService:
|
|||||||
_services: dict[str, dict]
|
_services: dict[str, dict]
|
||||||
# key = (key, group_id)
|
# key = (key, group_id)
|
||||||
_sub_list: dict[(str, str), Callable[[
|
_sub_list: dict[(str, str), Callable[[
|
||||||
str, MipsServiceState, dict], asyncio.Future]]
|
str, MipsServiceState, dict], Coroutine]]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, aiozc: AsyncZeroconf,
|
self, aiozc: AsyncZeroconf,
|
||||||
@ -207,7 +207,7 @@ class MipsService:
|
|||||||
|
|
||||||
def sub_service_change(
|
def sub_service_change(
|
||||||
self, key: str, group_id: str,
|
self, key: str, group_id: str,
|
||||||
handler: Callable[[str, MipsServiceState, dict], asyncio.Future]
|
handler: Callable[[str, MipsServiceState, dict], Coroutine]
|
||||||
) -> None:
|
) -> None:
|
||||||
if key is None or group_id is None or handler is None:
|
if key is None or group_id is None or handler is None:
|
||||||
raise MipsServiceError('invalid params')
|
raise MipsServiceError('invalid params')
|
||||||
|
|||||||
@ -52,7 +52,7 @@ import socket
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional, Coroutine
|
||||||
import psutil
|
import psutil
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class MIoTNetwork:
|
|||||||
|
|
||||||
_sub_list_network_status: dict[str, Callable[[bool], asyncio.Future]]
|
_sub_list_network_status: dict[str, Callable[[bool], asyncio.Future]]
|
||||||
_sub_list_network_info: dict[str, Callable[[
|
_sub_list_network_info: dict[str, Callable[[
|
||||||
InterfaceStatus, NetworkInfo], asyncio.Future]]
|
InterfaceStatus, NetworkInfo], Coroutine]]
|
||||||
|
|
||||||
_ping_address_priority: int
|
_ping_address_priority: int
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class MIoTNetwork:
|
|||||||
|
|
||||||
def sub_network_info(
|
def sub_network_info(
|
||||||
self, key: str,
|
self, key: str,
|
||||||
handler: Callable[[InterfaceStatus, NetworkInfo], asyncio.Future]
|
handler: Callable[[InterfaceStatus, NetworkInfo], Coroutine]
|
||||||
) -> None:
|
) -> None:
|
||||||
self._sub_list_network_info[key] = handler
|
self._sub_list_network_info[key] = handler
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user