mirror of
https://github.com/Andre0512/pyhOn.git
synced 2025-05-19 09:25:10 -04:00
Improve mqtt client
This commit is contained in:
parent
bef55f7abc
commit
11da4ebfbc
5 changed files with 125 additions and 93 deletions
|
@ -7,12 +7,10 @@ from types import TracebackType
|
|||
from typing import Dict, Optional, Any, List, no_type_check, Type
|
||||
|
||||
from aiohttp import ClientSession
|
||||
from awscrt import mqtt5
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyhon import const, exceptions
|
||||
from pyhon.appliance import HonAppliance
|
||||
from pyhon.connection import mqtt
|
||||
from pyhon.connection.auth import HonAuth
|
||||
from pyhon.connection.handler.anonym import HonAnonymousConnectionHandler
|
||||
from pyhon.connection.handler.hon import HonConnectionHandler
|
||||
|
@ -40,7 +38,6 @@ class HonAPI:
|
|||
self._hon_handler: Optional[HonConnectionHandler] = None
|
||||
self._hon_anonymous_handler: Optional[HonAnonymousConnectionHandler] = None
|
||||
self._session: Optional[ClientSession] = session
|
||||
self._mqtt_client: mqtt5.Client | None = None
|
||||
|
||||
async def __aenter__(self) -> Self:
|
||||
return await self.create()
|
||||
|
@ -269,10 +266,6 @@ class HonAPI:
|
|||
result: Dict[str, Any] = await response.json()
|
||||
return result
|
||||
|
||||
async def subscribe_mqtt(self, appliances: list[HonAppliance]) -> None:
|
||||
if not self._mqtt_client:
|
||||
self._mqtt_client = await mqtt.start(self, appliances)
|
||||
|
||||
async def close(self) -> None:
|
||||
if self._hon_handler is not None:
|
||||
await self._hon_handler.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue