Sonoff tasmota MQTT duplicate entries

I have quite a few POW R2s that all have duplicate entries for the switch (or maybe online state of the sonoff box itself) that I have in history and would like to get rid off.
I use hassio, so I use the integrated mosquitto and it’s autodiscovery and I would like not to have to configure each switch and sensor manually.

This is my config and what i’m writing about. Switches that show unavailable are the ones that were newly flashed with 6.5, the one that shows off are the ones that are upgraded for year or so.

What I would like is to have only one entry for each Pow r2 switch - unavailable when it is is offline/on when it is on and off when it is off. :slight_smile:

Do you get this with your duplicate entries:

E.G. the original entity was switch.yourdevice and now you have 2 entries switch.yourdevice_2? Which in the end are the same entity?

If the answer is yes than the solution is simple, restart your mqtt broker.

Not really state is different for switch.yourdevice and switch.yourdevice_2 and i tried restarting mosqitto plugin and it did not change anything.

I mean, they are the same entity, but only the second entity will do something? I had this problem, that is why I ask.

It happened after updating tasmota, and it started recreating all my entities but then with a _2 suffix (e.g. switch.fan_2). Only the ones with the suffix would work and the other entities would be rendered useless. States won’t change and commands no longer accepted (but they are with the newly created ones).

Restarting my broker solved it for me. Do you use discovery? Or did you hardcode the entities in Home Assistant (meaning you have created a config in switch/sensor platform manually?). If you use discovery, what you could do is remove the integration, restart Home Assistant and re-add the integration. Else you will need to clear out your mqtt broker (srry don’t know exactly how to do that). Ultimately you could force a restart on all tasmota devices (make sure the broker is empty/clean from older entries). Reflashing might help as well but I would only consider doing that as a last last last but I mean really last resort.

You might find an answer on clearing mosquitto here (not sure though)

Edit: if nothing helps, just change all your automations etc and add the suffix to those entities. It should work again then. I did that the first time it happened.

Btw it might be a completely different problem that you have got, I just share my experience.

1 Like