diff options
author | Nicolas Hennion <nicolashennion@gmail.com> | 2024-03-30 17:31:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-30 17:31:46 +0100 |
commit | 9c94effe05f9a0c7f7052d56cb99d9127aefad9f (patch) | |
tree | 1c8bf908a0cb9e3df188a56abfe4ec637ffc451e | |
parent | 7c430dd6ec599244e77af89565449c176602b518 (diff) | |
parent | f3b8b55ade4529e00095a412ff93ffac2ee16e04 (diff) |
Merge pull request #2712 from mpkossen/develop
Use enum instead of int for callback API version.
-rwxr-xr-x | glances/exports/mqtt/__init__.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/glances/exports/mqtt/__init__.py b/glances/exports/mqtt/__init__.py index a3202a65..94279749 100755 --- a/glances/exports/mqtt/__init__.py +++ b/glances/exports/mqtt/__init__.py @@ -63,12 +63,18 @@ class Export(GlancesExport): def init(self): # Get the current callback api version self.callback_api_version = int(self.callback_api_version) or 2 + + # Set enum for connection + if self.callback_api_version == 1: + self.callback_api_version = paho.CallbackAPIVersion.VERSION1 + else: + self.callback_api_version = paho.CallbackAPIVersion.VERSION2 """Init the connection to the MQTT server.""" if not self.export_enable: return None try: - client = paho.Client(client_id='glances_' + self.devicename, clean_session=False) + client = paho.Client(callback_api_version=self.callback_api_version, client_id='glances_' + self.devicename, clean_session=False) client.username_pw_set(username=self.user, password=self.password) if self.tls: client.tls_set(certifi.where()) |