Hi to all.
I’ve installed two new devices with custom tasmota firmware.
Untile here all ok, I was able to enable the auto-discovery and the devices appear on HA.
The problem is with the switch. As soon I turn it on via HA, the switch gets immediatly off. I can see the mqtt message from HA that starts (seems) correctly. I think it has with retain to do.
So, In a discovery setup, how can I disable the retain option for that switc without configure the entire entity in the HS configuration?
Thanks!
Simon
This seems to be a issue in the new tasmota 7 versions, I’ve too been having this issue after upgrading my tasmota 6 devices to tasmota 7.
I suppose you have not a solution yet. Workarounds @jasperro ?
I guess downgrading the tasmota version from 7 to 6 should work.
Hello!
I’m trying to debug the whole, but not sure what wrong.
If some Home Assistant guru could help, here some detailed logs:
Well, the device, a power plug, is on Tasmota 7.1.1.1. As soon I enable the auto discovery, many messages are sent to MQTT server. I think that the important one to configure the relay is:
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_1/config: b'{"name":"Tasmota","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","val_tpl":"{{value_json.POWER}}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_RL_1","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/"}'
(...)
[homeassistant.components.mqtt.discovery] Found new component: switch 522689_RL_1
The above config command is translated into readable formatted json:
{
"name":"Tasmota",
"cmd_t":"~cmnd/POWER",
"stat_t":"~tele/STATE",
"val_tpl":"{{value_json.POWER}}",
"pl_off":"OFF",
"pl_on":"ON",
"avty_t":"~tele/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"522689_RL_1",
"device":{
"identifiers":[
"522689"
],
"connections":[
[
"mac",
"84:0D:8E:52:26:89"
]
]
},
"~":"tasmota02/"
}
Seems OK, so, a new device is discovered and called switch.tasmota
.
As soon I try to turn it ON I can see the message goes out and the status comes back:
[homeassistant.components.mqtt] Transmitting message on tasmota02/cmnd/POWER: ON
[homeassistant.components.mqtt] Received message on tasmota02/tele/STATE: b'{"Time":"2019-12-05T13:28:47","Uptime":"1T03:49:19","UptimeSec":100159,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":14,"POWER":{"STATE":"ON"},"Wifi":{"AP":1,"SSId":"XefilHQ","BSSId":"E0:28:6D:7B:CE:48","Channel":11,"RSSI":78,"LinkCount":1,"Downtime":"0T00:00:08"}}'
Wrong is, that after 1-2 seconds, the switch turns automatically OFF again.
SEEMS that the state_topic
is not followed "stat_t":"~tele/STATE"
, but seems correct.
Having the message back from the Tasmota device, means that the command is sent out correctly from HA to MQTT Broker to Tasmota. I can confirm that the message is correctly taken from Tasmota.
Due theswitch goes back OFF immediatly, the Tasmota stay always ON, but, if I turn the switch from HA ON and OFF fast, before the switch turns off by itself, I can send out two messages, ON and OFF. Those arrives to the Tasmota which turns ON (it was already ON) and then OFF!
So it seems more a Home Assistant Issue.
Seems like the optimistic
mode is OFF and the state_topic
is not taken into consideration.
I have no idea where to look the autoconfig in Home Assistant. I mean where to look which mqtt configuration has the switch.tasmota
, and which MQTT settings are applied.
My goal is to NOT configure those devices manually and let the auto discovery do the job for me.
Ideas?
Thanks!!
Simon
PS:
Here the whole MQTT messages received on HA durng the discovery process enabled on the Tasmota:
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_1/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_1/config: b'{"name":"Tasmota","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","val_tpl":"{{value_json.POWER}}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_RL_1","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/"}'
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_2/config: b''
[homeassistant.components.mqtt.discovery] Found new component: switch 522689_RL_1
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_2/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_3/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_3/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_4/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_4/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_5/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_5/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_6/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_6/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_7/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_7/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/light/522689_LI_8/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/switch/522689_RL_8/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_BTN_1/config: b'{"name":"Tasmota Button1","stat_t":"~stat/BUTTON1","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_BTN_1","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/","value_template":"{{value_json.STATE}}","pl_on":"TOGGLE","off_delay":1}'
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_BTN_2/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_BTN_3/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_BTN_4/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_1/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_2/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_3/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_4/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_5/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_6/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_7/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/binary_sensor/522689_SW_8/config: b''
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_TotalStartTime/config: b'{"name":"Tasmota ENERGY TotalStartTime","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_TotalStartTime","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":" ","val_tpl":"{{value_json[\'ENERGY\'].TotalStartTime}}"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Total/config: b'{"name":"Tasmota ENERGY Total","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Total","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":"kWh","val_tpl":"{{value_json[\'ENERGY\'].Total}}","dev_cla":"power"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Yesterday/config: b'{"name":"Tasmota ENERGY Yesterday","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Yesterday","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":"kWh","val_tpl":"{{value_json[\'ENERGY\'].Yesterday}}","dev_cla":"power"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Today/config: b'{"name":"Tasmota ENERGY Today","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Today","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":"kWh","val_tpl":"{{value_json[\'ENERGY\'].Today}}","dev_cla":"power"}'
[homeassistant.components.mqtt.discovery] Found new component: binary_sensor 522689_BTN_1
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_TotalStartTime
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Total
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Yesterday
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Today
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Power/config: b'{"name":"Tasmota ENERGY Power","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Power","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":"W","val_tpl":"{{value_json[\'ENERGY\'].Power}}","dev_cla":"power"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_ApparentPower/config: b'{"name":"Tasmota ENERGY ApparentPower","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_ApparentPower","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":" ","val_tpl":"{{value_json[\'ENERGY\'].ApparentPower}}"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_ReactivePower/config: b'{"name":"Tasmota ENERGY ReactivePower","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_ReactivePower","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":" ","val_tpl":"{{value_json[\'ENERGY\'].ReactivePower}}"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Factor/config: b'{"name":"Tasmota ENERGY Factor","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Factor","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":" ","val_tpl":"{{value_json[\'ENERGY\'].Factor}}"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Voltage/config: b'{"name":"Tasmota ENERGY Voltage","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Voltage","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":"V","val_tpl":"{{value_json[\'ENERGY\'].Voltage}}","dev_cla":"power"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_ENERGY_Current/config: b'{"name":"Tasmota ENERGY Current","stat_t":"~SENSOR","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"522689_ENERGY_Current","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]]},"~":"tasmota02/tele/","unit_of_meas":"A","val_tpl":"{{value_json[\'ENERGY\'].Current}}","dev_cla":"power"}'
[homeassistant.components.mqtt] Received message on XefilHome/sensor/522689_status/config: b'{"name":"Tasmota status","stat_t":"~HASS_STATE","avty_t":"~LWT","pl_avail":"Online","pl_not_avail":"Offline","json_attributes_topic":"~HASS_STATE","unit_of_meas":" ","val_tpl":"{{value_json[\'RSSI\']}}","ic":"mdi:information-outline","uniq_id":"522689_status","device":{"identifiers":["522689"],"connections":[["mac","84:0D:8E:52:26:89"]],"name":"Tasmota","model":"Gosund SP1 v23","sw_version":"7.1.1.1(tasmota)","manufacturer":"Tasmota"},"~":"tasmota02/tele/"}'
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Power
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_ApparentPower
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_ReactivePower
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Factor
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Voltage
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_ENERGY_Current
[homeassistant.components.mqtt.discovery] Found new component: sensor 522689_status
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/STATE
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/LWT
[homeassistant.components.mqtt] Subscribing to tasmota02/stat/BUTTON1
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/SENSOR
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/HASS_STATE
[homeassistant.components.mqtt] Received message on tasmota02/tele/LWT (retained): b'Online'
[homeassistant.components.mqtt] Subscribing to tasmota02/tele/HASS_STATE
I had the same problem. For now I’ve rolledback to 6.7.1. For me the last known working.
Hello @Luitertje and @jasperro
It’s possible for someone of you execute from Tasmota the commands to disable and re-enable the auto discovery? I would like if there is a difference with what above.
A test like mine would be perfect.
Thanks, Simon
If Only I could build the flow HASS identifies the mqtt structure I could understand if the problem is on HASS or Tasmota…
Hello,
I’ve added a manual config as well, but wont work… I’ve leaved the auto discovery and added the following:
- platform: mqtt
name: tasmota_test
command_topic: "tasmota02/cmnd/POWER"
state_topic: "tasmota02/tele/STATE"
payload_on: "ON"
payload_off: "OFF"
value_template: "{{value_json.POWER}}"
state_on: "ON"
state_off: "OFF"
Again, the power command is sent and received on the tasmota, but the switch goes off immediatly.
The state answer is always as follor:
{
"Time":"2019-12-06T17:30:55",
"Uptime":"2T07:51:27",
"UptimeSec":201087,
"Heap":27,
"SleepMode":"Dynamic",
"Sleep":50,
"LoadAvg":27,
"MqttCount":14,
"POWER":{
"STATE":"ON"
},
"Wifi":{
"AP":1,
"SSId":"XefilHQ",
"BSSId":"E0:28:6D:7B:CE:48",
"Channel":11,
"RSSI":82,
"LinkCount":1,
"Downtime":"0T00:00:08"
}
}
Is the HA conf / topic configured correctly?
Thanks,
@jasperro and @Luitertje good news. Update to latest devel, it works!
I’m using 7.1.2.4 with custom prefix too, and happy!
Effelle wrote in chat:
Hi @Xefil. On 6.7 we got issue with HA not correctly read the binary_sensor topic. Is working but HA trows a lot of warning. Since no devs replied to our questions I decided to change the topic for buttons/switches.
The issue you had on 7.x was because a change on STATE topic on core code, not HA integration, and was already fixed and available on dev firmwares. Give it a spin!
probably will solve your retained messages too, since it will be able to send them.
And it works!
I’m late to the party but I’ll explain what I believe to have been the source of the original problem (and it was not due to a retained message).
Here’s part of the auto-discovery data:
"stat_t":"~tele/STATE",
"val_tpl":"{{value_json.POWER}}",
"pl_off":"OFF",
"pl_on":"ON",
It’s telling Home Assistant to create a switch that subscribes to topic ~tele/STATE
(which is tasmota02/tele/STATE
after the tilde is replaced) to extract data from the topic using this template {{value_json.POWER}}
and the result of this extraction will be either ON
or OFF
.
If Home Assistant commands a switch to turn on
and it never receives an acknowledgement from the device, it will automatically set the switch back to OFF
. This means there may be something wrong with the state_topic, value_template, or the expected payload (or some combination of the three).
The problem is the value_template; it fails to extract the correct payload. This template:
{{ value_json.POWER }}
will extract this from the payload:
{'STATE': 'ON'}
and that’s not a match for ON
specified by this:
"pl_on":"ON"
The correct value_template would be:
{{ value_json.POWER.STATE }}
Thanks @123 for the explanation I’ll share it on Tasmota as well.
Bye, Simon
Hi,
That template POWER:{STATE:ON} was reverted. It is not used any longer. It was in the Tasmota repository for few hours and was reverted back due it was breaking backwards compatibility with several other tools. So, just updating to latest Tasmota from the development branch, solves this issue. Thanks