Skip to content

Commit

Permalink
refactor: refactor miot mips & fix type errors (#365)
Browse files Browse the repository at this point in the history
* remove use of tev & fix type errors

* lint fix

* make private classes private

* simplify inheritance

* fix thread naming

* fix the deleted public data class

* remove tev

* fix access violation

* style: format code

* style: param init

* fix: fix event async set

* fix: fix mips re-connect error

---------

Co-authored-by: topsworld <[email protected]>
  • Loading branch information
chemwolf6922 and topsworld authored Jan 10, 2025
1 parent 152933a commit 9ceca34
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 1,079 deletions.
4 changes: 2 additions & 2 deletions custom_components/xiaomi_home/miot/miot_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ async def deinit_async(self) -> None:
# Cloud mips
self._mips_cloud.unsub_mips_state(
key=f'{self._uid}-{self._cloud_server}')
self._mips_cloud.disconnect()
self._mips_cloud.deinit()
# Cancel refresh cloud devices
if self._refresh_cloud_devices_timer:
self._refresh_cloud_devices_timer.cancel()
Expand All @@ -370,7 +370,7 @@ async def deinit_async(self) -> None:
for mips in self._mips_local.values():
mips.on_dev_list_changed = None
mips.unsub_mips_state(key=mips.group_id)
mips.disconnect()
mips.deinit()
if self._mips_local_state_changed_timers:
for timer_item in (
self._mips_local_state_changed_timers.values()):
Expand Down
324 changes: 0 additions & 324 deletions custom_components/xiaomi_home/miot/miot_ev.py

This file was deleted.

4 changes: 2 additions & 2 deletions custom_components/xiaomi_home/miot/miot_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import asyncio
import logging
import os
from typing import Optional
from typing import Optional, Union

# pylint: disable=relative-beyond-top-level
from .common import load_json_file
Expand Down Expand Up @@ -98,7 +98,7 @@ async def deinit_async(self) -> None:

def translate(
self, key: str, replace: Optional[dict[str, str]] = None
) -> str | dict | None:
) -> Union[str, dict, None]:
result = self._data
for item in key.split('.'):
if item not in result:
Expand Down
Loading

0 comments on commit 9ceca34

Please sign in to comment.