From 06ecda246b9c49a7e709ef43ae1f409260a0f02f Mon Sep 17 00:00:00 2001 From: Alex Muthmann Date: Fri, 15 Jan 2021 16:12:32 +0100 Subject: [PATCH 1/3] Support for MQTT Configuration in a single Backlog command --- README.md | 11 ++++++++++- defaults/main.yml | 10 ++++++++++ tasks/main.yml | 13 +++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6dc5f5b..1b945ab 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,17 @@ Available variables are listed below, along with their default values: tasmota_user: '' tasmota_password: '' tasmota_commands: [] + tasmota_mqtt_user: '' + tasmota_mqtt_password: '' + tasmota_mqtt_host: '' + tasmota_mqtt_port: '' + tasmota_mqtt_client: '' + tasmota_mqtt_topic: '' + tasmota_mqtt_fulltopic: '' -If tasmota_user and tasmota password are both non empty, they will be included in the commands to authenticate access. +If tasmota_user and tasmota password are both non-empty, they will be included in the commands to authenticate access. + +If any of the mqtt configuration values is set, a single `Backlog` command will be issued automatically after running the commands. Tasmota commands contains list of tasmota commands to be executed. Each tasmota_command is defined as: diff --git a/defaults/main.yml b/defaults/main.yml index cbdb6da..7ac3e1e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,15 @@ tasmota_user: '' tasmota_password: '' + +# MQTT Configuration, is run in a single command (backlog) to prevent multiple restarts +tasmota_mqtt_user: '' +tasmota_mqtt_password: '' +tasmota_mqtt_host: '' +tasmota_mqtt_port: '' +tasmota_mqtt_client: '' +tasmota_mqtt_topic: '' +tasmota_mqtt_fulltopic: '' + tasmota_commands: [] # examples: # set teleperiod to 10 seconds diff --git a/tasks/main.yml b/tasks/main.yml index fa186ae..ec62e17 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,3 +3,16 @@ command: "{{ item.command }}" value: "{{ item.value }}" with_items: "{{ tasmota_commands }}" + +- name: "Setup MQTT." + tasmota: + command: "Backlog" + value: > + MqttHost {{ tasmota_mqtt_host }}; + MqttUser {{ tasmota_mqtt_user }}; + MqttPassword {{ tasmota_mqtt_password }}; + MqttClient {{ tasmota_mqtt_client }}; + MqttTopic {{ tasmota_mqtt_topic }}; + MqttFullTopic {{ tasmota_mqtt_fulltopic }}; + when: (tasmota_mqtt_user + tasmota_mqtt_password + tasmota_mqtt_host + tasmota_mqtt_port + tasmota_mqtt_client + tasmota_mqtt_topic + tasmota_mqtt_fulltopic) | length > 0 + no_log: true From 93c447bf02d0767320b3f416049f69d86b6da247 Mon Sep 17 00:00:00 2001 From: Alex Muthmann Date: Fri, 15 Jan 2021 16:14:18 +0100 Subject: [PATCH 2/3] Support for MQTT Configuration in a single Backlog command --- tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/main.yml b/tasks/main.yml index ec62e17..66e4bde 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,7 @@ command: "Backlog" value: > MqttHost {{ tasmota_mqtt_host }}; + MqttPort {{ tasmota_mqtt_port }}; MqttUser {{ tasmota_mqtt_user }}; MqttPassword {{ tasmota_mqtt_password }}; MqttClient {{ tasmota_mqtt_client }}; From ff596fed4688f9f34e5df016a1a2835ebabcc5c8 Mon Sep 17 00:00:00 2001 From: Alex Muthmann Date: Fri, 15 Jan 2021 16:28:03 +0100 Subject: [PATCH 3/3] Support for MQTT Configuration in a single Backlog command --- tasks/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 66e4bde..143c89d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,5 +15,8 @@ MqttClient {{ tasmota_mqtt_client }}; MqttTopic {{ tasmota_mqtt_topic }}; MqttFullTopic {{ tasmota_mqtt_fulltopic }}; - when: (tasmota_mqtt_user + tasmota_mqtt_password + tasmota_mqtt_host + tasmota_mqtt_port + tasmota_mqtt_client + tasmota_mqtt_topic + tasmota_mqtt_fulltopic) | length > 0 + when: > + (tasmota_mqtt_user + tasmota_mqtt_password + tasmota_mqtt_host + tasmota_mqtt_port + + tasmota_mqtt_client + tasmota_mqtt_topic + tasmota_mqtt_fulltopic) + | length > 0 no_log: true