Skip to content

Commit

Permalink
Adjust callback type
Browse files Browse the repository at this point in the history
  • Loading branch information
DCSBL committed Nov 17, 2024
1 parent e9443e7 commit 3c2a743
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions homewizard_energy/v2/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
if TYPE_CHECKING:
from . import HomeWizardEnergyV2

OnMessageCallbackType = Callable[[str, Device | Measurement | System], None]

_LOGGER = logging.getLogger(__name__)


Expand All @@ -22,7 +24,8 @@ class Websocket:

_connect_lock: asyncio.Lock = asyncio.Lock()
_ws_connection: aiohttp.ClientWebSocketResponse | None = None
_ws_subscriptions: list[tuple[str, Callable[[aiohttp.WSMessage], None]]] = []
_ws_subscriptions: list[tuple[str, OnMessageCallbackType]] = []

_ws_authenticated: bool = False

def __init__(self, parent: "HomeWizardEnergyV2"):
Expand Down Expand Up @@ -65,7 +68,7 @@ async def disconnect(self) -> None:
self._ws_connection = None

def subscribe(
self, topic: WebsocketTopic, ws_callback: Callable[[aiohttp.WSMessage], None]
self, topic: WebsocketTopic, ws_callback: OnMessageCallbackType
) -> Callable[[], None]:
"""
Subscribe to raw websocket messages.
Expand Down

0 comments on commit 3c2a743

Please sign in to comment.