Home Assistant Unofficial Reference 2024.12.1
subscriber.py
Go to the documentation of this file.
1 """Subscriber for devolo home control API publisher."""
2 
3 from collections.abc import Callable
4 import logging
5 
6 _LOGGER = logging.getLogger(__name__)
7 
8 
9 class Subscriber:
10  """Subscriber class for the publisher in mprm websocket class."""
11 
12  def __init__(self, name: str, callback: Callable) -> None:
13  """Initiate the subscriber."""
14  self.namename = name
15  self.callbackcallback = callback
16 
17  def update(self, message: str) -> None:
18  """Trigger hass to update the device."""
19  _LOGGER.debug('%s got message "%s"', self.namename, message)
20  self.callbackcallback(message)