Added documentation
This commit is contained in:
parent
c2aa2f5adc
commit
fd414c2cd1
1 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
from typing import Optional
|
||||
from mash.bridges.bridge import Bridge
|
||||
import paho.mqtt.client as mqtt
|
||||
|
@ -15,6 +16,14 @@ class Z2mBridge(Bridge):
|
|||
keepalive: int = 60,
|
||||
topic: str = "zigbee2mqtt",
|
||||
) -> None:
|
||||
"""
|
||||
Args:
|
||||
id (str): Unique identifier of this bridge instance.
|
||||
ip (str): IP-Address of MQTT broker.
|
||||
port (int, optional): Port of MQTT broker. Defaults to 1883.
|
||||
keepalive (int, optional): MQTT keepalive delay in seconds. Defaults to 60.
|
||||
topic (str, optional): Base topic for Zigbee2MQTT interface. Defaults to "zigbee2mqtt".
|
||||
"""
|
||||
super().__init__(id=id, type="zigbee2mqtt")
|
||||
self._ip = ip
|
||||
self._port = port
|
||||
|
@ -37,10 +46,12 @@ class Z2mBridge(Bridge):
|
|||
def disconnect(self) -> None:
|
||||
self._client.loop_stop()
|
||||
self._client.disconnect()
|
||||
logging.info(f"Disconnected from Zigbee2MQTT broker [{self.id}].")
|
||||
|
||||
def connect(self) -> None:
|
||||
self._client.connect(self._ip, self._port, self._keepalive)
|
||||
self._client.loop_start()
|
||||
logging.info(f"Connect to Zigbee2MQTT broker [{self.id}].")
|
||||
|
||||
def __on_connect__(self, client, userdata, flags, reason_code, properties):
|
||||
self._client.subscribe(f"{self._topic}/#")
|
||||
|
|
Loading…
Reference in a new issue