tobias-richter / ansible-tasmota

Ansible Role for managing tasmota devices with tasmota commands
Apache License 2.0
31 stars 13 forks source link

Submitting JSON fails due to invalid encoding #21

Closed deveth0 closed 3 years ago

deveth0 commented 3 years ago

I first had the issue with Templates but it seems to be consistent for other commands like Timers.

Setting a command like this:

    - command: Timer16
      value: '{"Enable":1,"Mode":0,"Time":"11:44","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":3}'

results in this request (response: invalid json):

/cm?user=&password=&cmnd=Timer16+%7B%27Enable%27%3A+1%2C+%27Mode%27%3A+0%2C+%27Time%27%3A+%2711%3A44%27%2C+%27Window%27%3A+0%2C+%27Days%27%3A+%271111111%27%2C+%27Repeat%27%3A+1%2C+%27Output%27%3A+1%2C+%27Action%27%3A+3%7D

This is due to the fact, that instead of " only ' is used:

Timer16 {'Enable': 1, 'Mode': 0, 'Time': '11:44', 'Window': 0, 'Days': '1111111', 'Repeat': 1, 'Output': 1, 'Action': 3}

It does not matter, how you escape the value, the followin also fails:

    - command: Timer16
      value: "{'Enable':1,'Mode':0,'Time':'11:44','Window':0,'Days':'1111111','Repeat':1,'Output':1,'Action':3}"

Also the documented value for Template does not seem to work.

tobias-richter commented 3 years ago

@deveth0 merged #22 so this is fixed.