mirror of
https://github.com/Andre0512/pyhOn.git
synced 2026-06-19 23:19:39 +02:00
Improve mqtt client
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user