Flashing sonoff device remove previous settings

Hi , I beg for some help
I have struggling for a numbers days to get my sonoff switch to switch on with HA.
The HA switch just jumps back to off.
I have reinstalled Hassio twice and now installed Hassbian.
Also flashed the sonoff devices a number of times with Tasmota.

All this by following a number of videos, step by step and copying their examples and adding my details.

However I notice that when I re-flash the sonoff with Tasmota my old info is still there ??

How can I flash the device with a clean Bin file that does not remember any old settings ?

I think that my topics in HA and the Sonoff are not identical that why things are not working.

For some reason I think my Sonoff info is not the same as my HA switch command_topic etc


Clearing the flash

I presume you are using MQTT to communicate with the sonoff device?

If so make sure you go into the MQTT settings and check the topic is configured exactly as per HA - remember it’s case sensitive (IIRC)

1 Like

The problem is I dont know where to see if the correct topic is being used in the sonoff. I open the tasmota on the sonoff and added the topic sonoff2 to the field under MQTT menu and the same in the config file but still does not work.
Stupid question is dont know where to look to see if they the same.
Understand that they must be identical.
Sorry still learning all this. Apologies

Go to here: http://10.0.XXX.XX/mq? (replace the IP of mine with whatever your Sonoff IP is)

At the top you’ll see the “Host” input box, you’ll need to specify the MQTT broker there

Username and password if required

And then where it says topic, make sure you have the same topic there.

Your config on HA should look similar to below:

platform: mqtt
name: "Pergola Lights"
state_topic: "stat/PERGOLA_LIGHTS/POWER"
command_topic: "cmnd/PERGOLA_LIGHTS/POWER"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true

Note the difference between the state and command topics, I suspect this is where you are having issues.

Just to explain further, in my example above “PERGOLA_LIGHTS” is the topic name, you just put that into the config in the sonoff. The stat and comnd and power aspects are added automatically by the device.

use an MQTT sniffer to subscribe to all topics (#). I use MQTT.Fx as my sniffer of choice.

Once you subscribe to all topics you’ll see everything that is being passed around your MQTT network with the included payloads.

The Sonoff will retain your configuration across firmware updates. If you want to revert back to the default (which will be whatever you setup in the config file when you flashed Tasmota) you execute this command from the console:

reset 1
1 Like

Thanks to everyone above for the help , success at last. I reset the sonoff with the above command line " reset 1 " and the copied the switch settings above and change the topics to sonoff4 in tasmota and in the configuration. Yes success. Thanks guys for your time and effort , appreciate it.