Compare commits

...

16 Commits

Author SHA1 Message Date
Feng Wang
6535dda18c
Merge f614181755 into 7654e5e518 2024-12-24 21:05:23 +08:00
RangerCD
7654e5e518
fix: ignore undefined piid and keep processing following arguments (#377)
Some checks are pending
Tests / check-rule-format (push) Waiting to run
Validate / validate-hassfest (push) Waiting to run
Validate / validate-hacs (push) Waiting to run
Validate / validate-lint (push) Waiting to run
Validate / validate-setup (push) Waiting to run
2024-12-24 21:03:11 +08:00
Paul Shawn
0f5da18108
fix: fix unit convert attribute error (#396) 2024-12-24 21:02:36 +08:00
ZnDong
ea9aa082b7
docs: amend HACS installation (#404)
* docs: amend HACS installation

* docs: amend HACS installation
2024-12-24 21:02:17 +08:00
Feng Wang
f614181755 set timers to None after cancel 2024-12-22 20:26:54 +08:00
Feng Wang
fb46bc6b19 change internal class scope 2024-12-22 20:16:45 +08:00
Feng Wang
d3c39f38e1 remove unused data classes 2024-12-22 20:13:38 +08:00
Feng Wang
d13a6bfb11 fix racing condition 2024-12-22 19:51:58 +08:00
Feng Wang
463216d866 do not set asyncio event loop 2024-12-21 23:18:49 +08:00
Feng Wang
30e0433aee revert changes in the license 2024-12-21 23:16:30 +08:00
Feng Wang
0872bf4f69 ignore broad exception warning 2024-12-21 22:11:38 +08:00
Feng Wang
3f77738b90 fix lint 2024-12-21 22:02:19 +08:00
Feng Wang
f288a951b9 add tev back 2024-12-21 21:58:24 +08:00
Feng Wang
569e1512e3 fix lint 2024-12-21 21:52:45 +08:00
Feng Wang
794505f082 Use call_soon_threadsafe instead of event fd for ipc 2024-12-21 21:39:59 +08:00
Feng Wang
faa13c53e8 Remove tev & fix some type issues 2024-12-21 19:09:37 +08:00
8 changed files with 472 additions and 476 deletions

View File

@ -32,7 +32,7 @@ git checkout v1.0.0
### Method 2: [HACS](https://hacs.xyz/)
HACS > Overflow Menu > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category: Integration > ADD > Xiaomi Home in New or Available for download section of HACS > DOWNLOAD
HACS > Overflow Menu > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category or Type: Integration > ADD > Xiaomi Home in New or Available for download section of HACS > DOWNLOAD
> Xiaomi Home has not been added to the HACS store as a default yet. It's coming soon.

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

@ -1069,7 +1069,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={

View File

@ -628,7 +628,7 @@ class MIoTDevice:
# pylint: disable=import-outside-toplevel
from homeassistant.const import UnitOfConductivity
unit_map['μS/cm'] = UnitOfConductivity.MICROSIEMENS_PER_CM
except ImportError:
except Exception: # pylint: disable=broad-except
unit_map['μS/cm'] = 'μS/cm'
return unit_map.get(spec_unit, None)
@ -1198,8 +1198,8 @@ class MIoTEventEntity(Entity):
def __on_event_occurred(self, params: dict, ctx: Any) -> None:
_LOGGER.debug('event occurred, %s', params)
trans_arg = {}
try:
for item in params['arguments']:
for item in params['arguments']:
try:
if 'value' not in item:
continue
if 'piid' in item:
@ -1215,10 +1215,10 @@ class MIoTEventEntity(Entity):
for index, prop in enumerate(self.spec.argument)
}
break
except KeyError as error:
_LOGGER.error(
'on event msg, invalid args, %s, %s, %s',
self.entity_id, params, error)
except KeyError as error:
_LOGGER.debug(
'on event msg, invalid args, %s, %s, %s',
self.entity_id, params, error)
self.on_event_occurred(
name=self.spec.description_trans, arguments=trans_arg)
self.async_write_ha_state()

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,7 @@ import base64
import binascii
import copy
from enum import Enum
from typing import Callable, Optional
from typing import Callable, Optional, Coroutine
import logging
from zeroconf import (
@ -151,7 +151,7 @@ class MipsService:
_services: dict[str, dict]
# key = (key, group_id)
_sub_list: dict[(str, str), Callable[[
str, MipsServiceState, dict], asyncio.Future]]
str, MipsServiceState, dict], Coroutine]]
def __init__(
self, aiozc: AsyncZeroconf,
@ -207,7 +207,7 @@ class MipsService:
def sub_service_change(
self, key: str, group_id: str,
handler: Callable[[str, MipsServiceState, dict], asyncio.Future]
handler: Callable[[str, MipsServiceState, dict], Coroutine]
) -> None:
if key is None or group_id is None or handler is None:
raise MipsServiceError('invalid params')

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, Optional, Coroutine
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

View File

@ -32,7 +32,7 @@ git checkout v1.0.0
### 方法 2: [HACS](https://hacs.xyz/)
HACS > 右上角三个点 > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category: Integration > ADD > 点击 HACS 的 New 或 Available for download 分类下的 Xiaomi Home ,进入集成详情页 > DOWNLOAD
HACS > 右上角三个点 > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category or Type: Integration > ADD > 点击 HACS 的 New 或 Available for download 分类下的 Xiaomi Home ,进入集成详情页 > DOWNLOAD
> 米家集成暂未添加到 HACS 商店,敬请期待。