Merge pull request #746 from adebrouvier/main
Some checks are pending
docker / docker_dev (push) Waiting to run

Add MQTT TLS support by @adebrouvier 🙏
This commit is contained in:
jokob-sk
2024-07-24 08:24:16 +10:00
committed by GitHub
2 changed files with 36 additions and 2 deletions

View File

@@ -499,6 +499,38 @@
}
]
},
{
"function": "TLS",
"type": {
"dataType": "boolean",
"elements": [
{
"elementType": "input",
"elementOptions": [{ "type": "checkbox" }],
"transformers": []
}
]
},
"default_value": false,
"options": [],
"localized": ["name", "description"],
"name": [
{
"language_code": "en_us",
"string": "MQTT TLS"
}
],
"description": [
{
"language_code": "en_us",
"string": "Enable TLS support."
},
{
"language_code": "es_es",
"string": "Habilitar soporte TLS."
}
]
},
{
"function": "USER",
"type": {

View File

@@ -295,9 +295,11 @@ def mqtt_create_client():
if get_setting_value('MQTT_VERSION') == 1:
mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
else:
mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
if get_setting_value('MQTT_TLS'):
mqtt_client.tls_set()
mqtt_client.username_pw_set(get_setting_value('MQTT_USER'), get_setting_value('MQTT_PASSWORD'))
mqtt_client.on_connect = on_connect
mqtt_client.on_disconnect = on_disconnect