Giter Club home page Giter Club logo

ansible-tasmota's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-tasmota's Issues

Submitting JSON fails due to invalid encoding

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.

topic doesn't get set right

I updated the sonoff dual with tasmota 9.2. So everything latest. The MQTT topic won't get set up right.

I have both these in my ansible:

shortname: "{{  inventory_hostname.split('.')[0] | lower }}"
tasmota_mqtt_topic: "{{ shortname }}"
    sonoff-dual.ikenet:
        - command: topic
          value: "{{ shortname }}"

and from ansible playbook I can see it both from debug and the actual run that the topic is carried ok:

TASK [debug] ************************************************************************************************************
ok: [sonoff-dual.ikenet] => {
    "tasmota_commands": [
        {
            "command": "poweronstate",
            "value": 1
        },
        {
            "command": "friendlyname1",
            "value": "sonoff-dual"
        },
        {
            "command": "module",
            "value": 5
        },
        {
            "command": "topic",
            "value": "sonoff-dual"
        }
    ]
}

TASK [debug] ************************************************************************************************************
ok: [sonoff-dual.ikenet] => {
    "tasmota_mqtt_host": "mqtt.ikenet"
}

TASK [debug] ************************************************************************************************************
ok: [sonoff-dual.ikenet] => {
    "tasmota_mqtt_port": "1883"
}

TASK [debug] ************************************************************************************************************
ok: [sonoff-dual.ikenet] => {
    "tasmota_mqtt_client": "sonoff-dual"
}

TASK [debug] ************************************************************************************************************
ok: [sonoff-dual.ikenet] => {
    "tasmota_mqtt_topic": "sonoff-dual"
}
TASK [tobias_richter.tasmota : Configure tasmota.] **********************************************************************
changed: [sonoff-dual.ikenet] => (item={'command': 'poweronstate', 'value': 1})
changed: [sonoff-dual.ikenet] => (item={'command': 'friendlyname1', 'value': 'sonoff-dual'})
changed: [sonoff-dual.ikenet] => (item={'command': 'module', 'value': 5})
changed: [sonoff-dual.ikenet] => (item={'command': 'topic', 'value': 'sonoff-dual'})

TASK [tobias_richter.tasmota : Setup MQTT.] *****************************************************************************
changed: [sonoff-dual.ikenet]

so definitely the ansible get's the topic for the role, but it doesn't get set in tasmota. The host specific command for topic should not be needed, but I tried forcing it. However, after such run the topic is "tasmota_%06X" in tasmota GUI.

Error on configure tasmota task

Hello, I'm receiving the following error, not sure if I'm doing something wrong-

PLAY [test] *****************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [tobias_richter.tasmota : Configure tasmota.] **************************************************************************************************************************************************************************************************************************************************************************
fatal: [TAS_LR_Soundbar.tc.local]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'value'\n\nThe error appears to be in '/home/josh/roles/tobias_richter.tasmota/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: \"Configure tasmota.\"\n  ^ here\n"}

Any advice would be appreciated.

Password incorrectly parsed when coming from Ansible Vault

Hi,

Before anything else, thank you for this role. It's great.

When the password is defined in an Ansible Vault, which is my case, the password in the status_params dictionary is of type ansible.parsing.yaml.objects.AnsibleVaultEncryptedUnicode. As a consequence, it is incorrectly processed by the requests.get() method: if password is 123, the resulting uri is: cm/?user=theuser&password=1&password=2&password=3.

The simplest solution is to use str() when building the status_params dictionary. For extra safety I would apply this to all the values (because the username and the command can also be defined in the Vault).

I will submit a PR with a proposal to solve this issue.

Regards,
Nuno

older tasmotas fail due different answer format

Hi,

first of all, thanks for doing the role, looks really nice. I have a bunch of tasmota devices at home, and immediately went and tried this role. However, I noticed it won't work for the older modules that I have. At least that's what I thinki is the reason. The module get's some sort of wrong answer for the status query at the beginning. So perhaps it would be good to have some version check or something? Or handle different answers differently?

It seems to come down to this difference in answer:

╰─$ curl http://sonoff-rv/cm\?cmnd\=poweronstate
{"PowerOnState":1}

╰─$ curl http://sonoff-tp/cm\?cmnd\=poweronstate
RESULT = {"PowerOnState":1}

I don't know exactly when the format has changed, but seems the older ones have "RESULT = " before the json. This fails the role. I just went to try OTA update to one of my tasmota light swithces, but it died during the process.... I'll report back if I get it back alive one day. The version was 5.11.

Ansible-tasmota crashing on macOS 12.2.1 (21D62)

When running:

ansible-playbook playbooks/adjust_reporting_tasmotas.yaml

with the following playbook

- hosts: tasmotas
  gather_facts: no
  tasks:
    - name: Ensure device reports status
      include_role:
        name: tobias_richter.tasmota  
      vars:
        tasmota_commands:
          - command: Teleperiod
            value: 200

I get the following error:

han@MBP2018-2 Ansible % ansible-playbook playbooks/upgrade_tasmotas.yaml

PLAY [tasmotas] ***********************************************************************************************************************************************************

TASK [Ensure device reports status] ***************************************************************************************************************************************

TASK [tobias_richter.tasmota : Configure tasmota.] ************************************************************************************************************************
objc[75669]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[75669]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

This is related to:

ansible/ansible#32499 : OSX crash complaining of operation in progress in another thread when fork() was called #32499

Ist there anything I can do to prevent the error so this playbook is run?

Handling for MqttPassword / Passwords in general

Hey,

when setting the mqtt password using the ansible role, it is detected as change each time. Also the password is published in plaintext inside the playbook output:

changed: [tasmota_balkon_chirp] => (item={'command': 'MqttPassword', 'value': 'blubblub'})

I'm not sure, if we can solve the first problem, is there any best practive if such configs should return a "changed" or "ok"?

22:06:34.603 CMD: mqttpassword
22:06:34.611 MQT: stat/tasmota_balkon_chirp/RESULT = {"MqttPassword":"****"}

For the second problem: It is also relevant for the following configs:

  • Password
  • WebPassword

I guess we could set the no_log flag for all commands that contain "password", what do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.