From fd414c2cd18330899218e06cb0d1a522ccbb0d0b Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Wed, 17 Jul 2024 21:01:54 +0200 Subject: [PATCH] Added documentation --- src/mash/bridges/zigbee2mqtt.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mash/bridges/zigbee2mqtt.py b/src/mash/bridges/zigbee2mqtt.py index 3de16d0..ba98df6 100644 --- a/src/mash/bridges/zigbee2mqtt.py +++ b/src/mash/bridges/zigbee2mqtt.py @@ -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}/#")