Tasmota MQTT switches not always switching

I have set up two switches I have flashed with Tasmota 9.5.0, they are set with SetOption19 1. They show up on my lovelace dashboard as two switches, showing the current stated (on or off).

The problem is if I turn them on or off, a lot of the time the command doesn’t get passed to the switch. The dashboard switch will update it’s state for a second or two and then switch back & the switch itself never changed. If I go to the web interface for the switch & click toggle, it performs as expected 100% of the time and HA updates with the correct status.

I cannot see anything in the HA error logs.

Is anyone able to help me troubleshoot what is causing this problem?

I am running:
core 2021-9-2
supervisor-2021.09.0
operating system 6.2
mosquitto (working fine for my weather station)

Add this to configuration.yaml

logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug

Restart HA.

Open a tasmota console
Switch on/off in HA

Post both HA log and tasmota log.

Tasmota now recommend using Tasmota Discovery in HA. SetOption19 0 and add the tasmota integration in HA.

I setoption19 as 0, rebooted that switches & it shows up in HA, but still has the same symptoms, sometimes the switch works, sometimes it doesn’t

did you add the Tasmota integration?

I have added the logger to configuration.yaml as described.

The tasmota log repeats the following every second:

04:54:35.803 MQT: Connected
04:54:35.806 MQT: tele/tasmota_CACCCC/LWT = Online (retained)
04:54:35.810 MQT: cmnd/tasmota_CACCCC/POWER = 
04:54:36.477 RSL: config = {"name":"BedroomPlug","stat_t":"tele/tasmota_CACCCC/STATE","avty_t":"tele/tasmota_CACCCC/LWT","pl_avail":"Online","pl_not_avail":"Offline","cmd_t":"cmnd/tasmota_CACCCC/POWER","pl_off":"OFF","pl_on":"ON","val_tpl":"{{value_json.POWER}}","uniq_id":"CACCCC_RL_1","dev":{"ids":["CACCCC"]}}
04:54:36.487 RSL: config = {"name":"BedroomPlug status","stat_t":"tele/tasmota_CACCCC/HASS_STATE","avty_t":"tele/tasmota_CACCCC/LWT","pl_avail":"Online","pl_not_avail":"Offline","json_attr_t":"tele/tasmota_CACCCC/HASS_STATE","unit_of_meas":"%","val_tpl":"{{value_json['RSSI']}}","ic":"mdi:information-outline","uniq_id":"CACCCC_status","dev":{"ids":["CACCCC"],"name":"BedroomPlug","mdl":"Brilliant","sw":"9.5.0(tasmota)","mf":"Tasmota"}}

The HA log shows the following:

2021-09-05 16:04:00 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/sensors: b'{"sn":{"Time":"2021-09-05T05:04:00"},"ver":1}'
2021-09-05 16:04:00 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_CACCCC/LWT: b'Online'
2021-09-05 16:04:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_6BA2D7/LWT: b'Online'
2021-09-05 16:04:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/config: b'{"ip":"192.168.1.52","dn":"Coffee","fn":["Coffee",null,null,null,null,null,null,null],"hn":"tasmota_6BA2D7-0727","mac":"840D8E6BA2D7","md":"Brilliant","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.5.0","t":"tasmota_6BA2D7","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":1,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":1,"lt_st":0,"sho":[0,0,0,0],"ver":1}'
2021-09-05 16:04:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/sensors: b'{"sn":{"Time":"2021-09-05T05:04:01"},"ver":1}'
2021-09-05 16:04:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_CACCCC/LWT: b'Online'
2021-09-05 16:04:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_6BA2D7/LWT: b'Online'
2021-09-05 16:04:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/config: b'{"ip":"192.168.1.52","dn":"Coffee","fn":["Coffee",null,null,null,null,null,null,null],"hn":"tasmota_6BA2D7-0727","mac":"840D8E6BA2D7","md":"Brilliant","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.5.0","t":"tasmota_6BA2D7","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":1,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":1,"lt_st":0,"sho":[0,0,0,0],"ver":1}'
2021-09-05 16:04:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/sensors: b'{"sn":{"Time":"2021-09-05T05:04:02"},"ver":1}'
2021-09-05 16:04:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_CACCCC/LWT: b'Online'
2021-09-05 16:04:03 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_6BA2D7/LWT: b'Online'
2021-09-05 16:04:03 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/config: b'{"ip":"192.168.1.52","dn":"Coffee","fn":["Coffee",null,null,null,null,null,null,null],"hn":"tasmota_6BA2D7-0727","mac":"840D8E6BA2D7","md":"Brilliant","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.5.0","t":"tasmota_6BA2D7","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":1,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":1,"lt_st":0,"sho":[0,0,0,0],"ver":1}'
2021-09-05 16:04:03 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/sensors: b'{"sn":{"Time":"2021-09-05T05:04:03"},"ver":1}'
2021-09-05 16:04:03 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_CACCCC/LWT: b'Online'
2021-09-05 16:04:04 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_6BA2D7/LWT: b'Online'
2021-09-05 16:04:04 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/config: b'{"ip":"192.168.1.52","dn":"Coffee","fn":["Coffee",null,null,null,null,null,null,null],"hn":"tasmota_6BA2D7-0727","mac":"840D8E6BA2D7","md":"Brilliant","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.5.0","t":"tasmota_6BA2D7","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":1,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":1,"lt_st":0,"sho":[0,0,0,0],"ver":1}'
2021-09-05 16:04:04 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/sensors: b'{"sn":{"Time":"2021-09-05T05:04:04"},"ver":1}'
2021-09-05 16:04:04 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_CACCCC/LWT: b'Online'
2021-09-05 16:04:05 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/tasmota_6BA2D7/LWT: b'Online'
2021-09-05 16:04:05 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/config: b'{"ip":"192.168.1.52","dn":"Coffee","fn":["Coffee",null,null,null,null,null,null,null],"hn":"tasmota_6BA2D7-0727","mac":"840D8E6BA2D7","md":"Brilliant","ty":0,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.5.0","t":"tasmota_6BA2D7","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0,0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":1,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0,"117":0},"lk":1,"lt_st":0,"sho":[0,0,0,0],"ver":1}'
2021-09-05 16:04:05 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tasmota/discovery/840D8E6BA2D7/sensors: b'{"sn":{"Time":"2021-09-05T05:04:05"},"ver":1}'

This was after I toggled both of the ‘coffee’ and ‘bedroomplug’ switches.

Yes, Tasmota integration is added and showing 1 device, 10 entities

Strange, both logs do not show any commands. There should have been at least one command being sent.

sometimes I can see the following:

2021-09-05 16:14:21 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on cmnd/tasmota_6BA2D7/POWER: 'OFF', mid: 475
2021-09-05 16:14:22 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on cmnd/tasmota_6BA2D7/STATE: '', mid: 476

I am not sure whether this is one of the times the switch worked or not though.

do you have any manual mqtt configuration (yaml) in any file?

ALSO if using Tasmota Integration, you MUST SetOption19 0 (not 1) or it won’t work.

I have manual configuration for my weather station, snippet is as follows:

  - platform: mqtt
    name: "Temperature"
    icon: mdi:thermometer
    state_topic: "weather/outTemp_C"
    unit_of_measurement: "°C"
    value_template: "{{ (value | round(0)) | float }}"
  - platform: mqtt
    name: "Humidity"
    icon: mdi:water-percent
    state_topic: "weather/outHumidity"
    unit_of_measurement: "%"
    value_template: "{{ (value | round(0)) | float }}"

None of the names conflict & the weather station works as expected.

I have setoption19 set as 0 on one of the switches & 1 on the other - the change as you suggested. Both have the same symptoms - sometimes the switch works, sometimes it doesn’t

config should be ok for weather station. I have 7 tasmotised switches and all work correctly with no delay or problem.

HA can correctly read the state of the switch (which I think comes through mqtt), but can’t consistently change it.

are you using the switch from the integration? not trying to send MQTT commands?

Using the switch under config, devices, entity coffee. I suspect that it is the same location as the image you posted

1 Like

I have the exact same issue, did you ever figure out what was causing this?