Skip to content

Commit

Permalink
Merge pull request #2712 from mpkossen/develop
Browse files Browse the repository at this point in the history
Use enum instead of int for callback API version.
  • Loading branch information
nicolargo committed Mar 30, 2024
2 parents 7c430dd + f3b8b55 commit 9c94eff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion glances/exports/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ def __init__(self, config=None, args=None):
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())
Expand Down

0 comments on commit 9c94eff

Please sign in to comment.