Skip to content

Commit

Permalink
Merge branch 'master' into feature/mqtt_backlog
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-richter authored Jan 17, 2021
2 parents 1b1dc83 + f1204b3 commit c67819c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ e.g.
# make sure that TuyaMCU fnId is disabled or missing
- command: TuyaMCU
value: 11,0

# Example for no_log
- command: MqttPassword
value: MySafePassword
no_log: True

## Tipps

To avoid specifying `tasmota_commands` for each host using host_vars you can use a construct similar to this:
Expand Down
10 changes: 6 additions & 4 deletions action_plugins/tasmota.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def run(self, tmp=None, task_vars=None):

self._task_vars = task_vars
changed = False
no_log = self._play_context.no_log

display.v("args: %s" % (self._task.args))
if not no_log:
display.v("args: %s" % (self._task.args))

check_mode = task_vars['ansible_check_mode']
display.v("check_mode: %s" % (check_mode))
Expand All @@ -82,8 +84,8 @@ def run(self, tmp=None, task_vars=None):
display.v("got an exception: "+err.message)
return self._fail_result(result, "error during retrieving parameter '%s'" % (err.message))

display.v("incoming_value %s" % (incoming_value))

if not no_log:
display.v("incoming_value %s" % (incoming_value))

auth_params = {}
try:
Expand Down Expand Up @@ -191,7 +193,7 @@ def our_entry(x):
except Exception as e:
raise AnsibleRuntimeError("Invalid response payload: %s, error: %s" % (data, e))

display.v("[%s] command: %s, existing_value: '%s', incoming_value: '%s'" % (tasmota_host, command, existing_value, incoming_value))
display.v("[%s] command: %s, existing_value: '%s', incoming_value: '%s'" % (tasmota_host, command, existing_value, incoming_value if not no_log else ""))

display.v("[%s] existing_uri: %s" % (tasmota_host, endpoint_uri))
if existing_value != incoming_value:
Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ tasmota_commands: []
# enable one shot for the rule
# - command: Rule1
# value: 5
# set MqttPassword to "MySafePassword" with no_log
# - command: MqttPassword
# value: MySafePassword
# no_log: True
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
tasmota:
command: "{{ item.command }}"
value: "{{ item.value }}"
no_log: "{{ item.no_log | default(omit) }}"
with_items: "{{ tasmota_commands }}"

- name: "Setup MQTT."
Expand Down

0 comments on commit c67819c

Please sign in to comment.