Add mqtts support

This commit is contained in:
Ariel Debrouvier
2024-07-23 11:25:11 -03:00
parent 8b1b86eeb7
commit a31469373f
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", "function": "USER",
"type": { "type": {

View File

@@ -297,6 +297,8 @@ def mqtt_create_client():
else: 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.username_pw_set(get_setting_value('MQTT_USER'), get_setting_value('MQTT_PASSWORD'))
mqtt_client.on_connect = on_connect mqtt_client.on_connect = on_connect