Sonoff switches (Tasmota fw) sending random MQTT commands

Hi! I’ve been really interested in migrating my Sonoff switches to Tasmota firmware to be able to “disconnect” the physical switch (the one I touch with my hands) from the electronic switch.
I wanted this to be able to control some devices without having to rewire.

I flashed the Tasmota firmware on three devices (first flashed wirelessly with this script and then upgraded to v12.3.1 via OTA).

I have three switches, I used the Tasmota console to set two of them to switchmode1 15 (this unlinks the manual switch from the electronic one) and the other one is set to switchmode1 2 (this mantains on/off positions).

When I press them they work as expected, but all three devices are sending ON/OFF messages randomly every a couple of minutes (and one of my lights has been reacting to those messages since maybe an hour ago).

Any ideas of what could be happening here?

This is a capture of the MQTT listen:

I’m using the Mosquito broker inside HASS,
Home Assistant 2022.12.6
Supervisor 2022.11.2
Operating System 9.4
Frontend 20221213.0 - latest
This is running on a VirtualBox VM (has been running great these days) and currently there is 1GB of free RAM.


EDIT: I just noticed all the commands are OFF commands and always after a message with the wifi name, it might be a connectivity issue.

EDIT2: I thought this could be a router issue, so I switched routers (keeping wifi name and IP) and the problem persists… Is there any way to disable these messages? They are all being sent in the same order as the capture, first a /STATE message and then a /SENSOR OFF message.

Ok, so, I’ve been reading about this issue and apparently it’s normal that MQTT switches report their status every 5 minutes, this would cause an issue with retained message in some cases. I did a couple of things that solved the issue:
I went to the Console and sent “sensorretain on” and then “sensorretain off”, to make sure these messages weren’t being retained in the broker.
Then I had to configure these devices as MQTT binary sensors so Home Assistant wouldn’t react to each message received every 5 minutes.
I added this in the mqtt.yaml config file:

  - name: "Living Ceiling Key"
    state_topic: "tele/TAS-MINI-03-Ceiling/SENSOR"
    value_template: '{{ value_json.Switch1 }}'
    payload_on: "ON"
    payload_off: "OFF"

Now everything seems to be working just fine :slight_smile:


After a couple of days, I noticed that this was working fine except for when HA was restarted.
A couple of minutes after the restart, both devices would send a SENSOR command at the same time and this would cause issues (since now I have scenes that activate when these switches are flipped quickly).

The updated solution for this was to set them to sensorretain on through the Tasmota Console. Now I did many restarts without any issues.