From c9b351a08e31aa0c34892065f02f9ef710b6cd34 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sat, 24 Feb 2024 02:00:40 +0300 Subject: mqtt changes --- include/py/homekit/mqtt/_wrapper.py | 1 - include/py/homekit/mqtt/module/ota.py | 6 ++++-- include/py/homekit/temphum/base.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/py/homekit/mqtt/_wrapper.py b/include/py/homekit/mqtt/_wrapper.py index 5fc33fe..68af093 100644 --- a/include/py/homekit/mqtt/_wrapper.py +++ b/include/py/homekit/mqtt/_wrapper.py @@ -44,7 +44,6 @@ class MqttWrapper(Mqtt): except Exception as e: self._logger.exception(e) - def on_message(self, client: mqtt.Client, userdata, msg): try: topic = msg.topic diff --git a/include/py/homekit/mqtt/module/ota.py b/include/py/homekit/mqtt/module/ota.py index 2f9b216..16931e9 100644 --- a/include/py/homekit/mqtt/module/ota.py +++ b/include/py/homekit/mqtt/module/ota.py @@ -42,10 +42,12 @@ class OtaPayload(MqttPayload): class MqttOtaModule(MqttModule): _ota_request: Optional[tuple[str, int]] + _custom_ota_topic: Optional[str] - def __init__(self, *args, **kwargs): + def __init__(self, custom_ota_topic=None, *args, **kwargs): super().__init__(*args, **kwargs) self._ota_request = None + self._custom_ota_topic = custom_ota_topic def on_connect(self, mqtt: MqttNode): super().on_connect(mqtt) @@ -64,7 +66,7 @@ class MqttOtaModule(MqttModule): def do_push_ota(self, secret: str, filename: str, qos: int): payload = OtaPayload(secret=secret, filename=filename) - self._mqtt_node_ref.publish('ota', + self._mqtt_node_ref.publish('ota' if not self._custom_ota_topic else self._custom_ota_topic, payload=payload.pack(), qos=qos) diff --git a/include/py/homekit/temphum/base.py b/include/py/homekit/temphum/base.py index 602cab7..c9d5111 100644 --- a/include/py/homekit/temphum/base.py +++ b/include/py/homekit/temphum/base.py @@ -16,4 +16,4 @@ class BaseSensor(ABC): class SensorType(Enum): Si7021 = 'si7021' - DHT12 = 'dht12' \ No newline at end of file + DHT12 = 'dht12' -- cgit v1.2.3