tobias-richter / ansible-tasmota

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

topic doesn't get set right #19

Closed ikke-t closed 3 years ago

ikke-t commented 3 years ago

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.

ikke-t commented 3 years ago

seems to origin from tasmota, I created a ticket there: https://github.com/arendst/Tasmota/issues/10796

ikke-t commented 3 years ago

that was my fault. I used client-id the same as topic, which is not allowed, and sonoff changes the topic to default if done so. This would be great to be checked in ansible and have it fail if set so.

ikke-t commented 3 years ago

It seems there is still bug in topic setting, I'll do PR

tobias-richter commented 3 years ago

@deveth0 please have a look and give feedback since this is from you. PR is also available.

tobias-richter commented 3 years ago

@ikke-t regarding

This would be great to be checked in ansible and have it fail if set so.

Feel free to create a PR for this. Due to time limitations I can not take care of this.