From 2c9aad0cb062f5160c628bc2f7620bbc759dc64d Mon Sep 17 00:00:00 2001 From: Noah Kontur Date: Wed, 14 Sep 2022 01:50:35 -0400 Subject: [PATCH] Allow password authentication to be used in conjuction with TLS --- src/amcrest2mqtt.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 31054dd..612936f 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -210,6 +210,7 @@ topics = { mqtt_client = mqtt.Client( client_id=f"amcrest2mqtt_{serial_number}", clean_session=False ) +mqtt_client.username_pw_set(mqtt_username, password=mqtt_password) mqtt_client.on_disconnect = on_mqtt_disconnect mqtt_client.will_set(topics["status"], payload="offline", qos=mqtt_qos, retain=True) if mqtt_tls_enabled: @@ -230,8 +231,6 @@ if mqtt_tls_enabled: cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLS, ) -else: - mqtt_client.username_pw_set(mqtt_username, password=mqtt_password) try: mqtt_client.connect(mqtt_host, port=mqtt_port)