From 40834f7ce5552504d732f18a17cd9c0a5bb537d2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 11 Mar 2021 19:24:13 +0100 Subject: [PATCH] The zigbee2mqtt backend should use a suffix for the default client_id to prevent clashes with the default client_id from the MQTT backend [see #175] --- platypush/backend/zigbee/mqtt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platypush/backend/zigbee/mqtt.py b/platypush/backend/zigbee/mqtt.py index 9b58c0b4e..774bbc3fc 100644 --- a/platypush/backend/zigbee/mqtt.py +++ b/platypush/backend/zigbee/mqtt.py @@ -63,7 +63,7 @@ class ZigbeeMqttBackend(MqttBackend): tls_cafile: Optional[str] = None, tls_certfile: Optional[str] = None, tls_keyfile: Optional[str] = None, tls_version: Optional[str] = None, tls_ciphers: Optional[str] = None, username: Optional[str] = None, - password: Optional[str] = None, *args, **kwargs): + password: Optional[str] = None, client_id: Optional[str] = None, *args, **kwargs): """ :param host: MQTT broker host (default: host configured on the ``zigbee.mqtt`` plugin). :param port: MQTT broker port (default: 1883). @@ -80,6 +80,8 @@ class ZigbeeMqttBackend(MqttBackend): required, specify it here (default: None) :param username: Specify it if the MQTT server requires authentication (default: None) :param password: Specify it if the MQTT server requires authentication (default: None) + :param client_id: MQTT client ID (default: ``-zigbee-mqtt``, to prevent clashes with the + :class:`platypush.backend.mqtt.MqttBackend` ``client_id``. """ plugin = get_plugin('zigbee.mqtt') @@ -107,7 +109,9 @@ class ZigbeeMqttBackend(MqttBackend): ], }] - super().__init__(subscribe_default_topic=False, listeners=listeners, *args, **kwargs) + super().__init__(subscribe_default_topic=False, listeners=listeners, client_id=client_id, *args, **kwargs) + if not client_id: + self.client_id += '-zigbee-mqtt' def _process_state_message(self, client, msg): if msg == self._last_state: