MQTT switches working strange lately

It’s not a mystery. When you enable MQTT discovery the topic order changes as you describe. It is by design.

If you disable discovery SetOption19 0 it won’t revert back - you will need to manually edit it.

I also found out today that if you change core (which you have - probably gone from core 2.3 to core 2.6.1) you must do a reset 3 from the console and then power cycle the sonoff. Easiest way to power cycle in your case might be to hit the house circuit breakers.

I really suggest using discovery unless you have to have manual config. Flash the minimal version OTA and then the full one you compiled. Then do a Reset 3. When you have done them all, hit the breakers. This cleans the flash area and recalibrated WiFi as well. Then you should be all good.

David, I’m still on the fence about how to proceed. I do want to understand how to get rid of the two zombie sonoffs that I have from auto-discovery. I think that this is not too far off-topic. A year ago you posted this:

easiest way is by disabling discovery on the device so add it back again…

hard way…

remove mqtt integration
remove mqtt broker
restart home assistant
edit /admin/.storage/core.device_registry and delete the invalid entry
restart home assistant
verify zombie entries are still gone from core.device_registry
add mqtt broker
add mqtt integration
restart home assistant

Is the hard way still the best way to remove the zombie devices? If so, what are the actions to add and remove the mqtt broker? Do you just mean to start and stop mosquitto?

Thanks

To remove the broker just delete the addon (and then reinstall it)
However none of that should be needed anymore. You should be able to delete the devices/entities from the GUI. You can use MQTT Explorer to clean up the broker and remove all retained messages… so if you use that first and then the GUI to remove devices/entities you should be good.