Skip to content

Commit

Permalink
Merge pull request #17 from tobias-richter/feature/mqtt_backlog
Browse files Browse the repository at this point in the history
Support for MQTT Configuration in a single Backlog command
  • Loading branch information
tobias-richter authored Jan 26, 2021
2 parents 631f57b + 9b80984 commit bd919cc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@
value: "{{ item.value }}"
no_log: "{{ item.no_log | default(omit) }}"
with_items: "{{ tasmota_commands }}"

- name: "Setup MQTT."
tasmota:
command: "Backlog"
value: >
MqttHost {{ tasmota_mqtt_host }};
MqttPort {{ tasmota_mqtt_port }};
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

0 comments on commit bd919cc

Please sign in to comment.