Flash Tasmota on a Sonoff in DIY mode in Linux
Last Revision October 20. Original Version: August 22, 2019

ITEAD sells Sonoff Wi-Fi switches that have a DIY mode making it possible to turn the switch on or off locally with an HTTP request. Putting the Sonoff into DIY mode is straight forward: simply bridge two pins on a header with the supplied jumper. Using DIY mode is another matter and, consequently, the vast majority of those persons that would want to use DIY mode will replace the ITEAD firmware with something else such as Theo Arends' Tasmota.

While it is as easy as before to flash new firmware on the Sonoff Basic R3, it is more complicated on the Sonoff Mini because there are no provisions on the board for a four or five pin header dedicated to that purpose. Fortunately, DIY mode makes it possible to replace the firmware by wireless uploading (OTA) using the Sonoff_Devices_DIY_Tools provided by ITEAD. However, that utility works in Windows 10 only and it also appears that many, including myself, ran into problems using it.

This post shows how I replaced the ITEAD firmware of a Sonoff Mini with Tasmota using the OTA capability of the DIY mode and a Web browser on a Linux desktop. A month later, Tasmota was flashed onto a Sonoff Basic R3 in the same way. The technique is flexible. It works in Linux, MacOS and probably Windows version 10 and older. Of course something other than Tasmota could be flashed. This works with Firefox and other browsers or cURL could be used instead. There is no such thing as a free lunch; the trade off is increased complexity.

  1. There must be a Web server on the local area network (LAN) that can download the replacement firmware. Many will probably have that in place if they are currently running a home automation system. Otherwise, it is a simple matter to install the required software.
  2. A Wi-Fi access point connected to the LAN must be set up. I have mostly used a MoCA network extender and a Wi-Fi router running OpenWrt for this but there are other possibilities that do not require this extra hardware as explained below.

Table of content

  1. Some Preliminaries
  2. Create a Wi-Fi Access Point
    1. With a Desktop HotSpot
    2. With a Guest Network
    3. With an OpenWrt Wi-Fi Router
    4. With a Network Extender
  3. Update the Sonoff Device
  4. Upload Tasmota to the Sonoff Device
    1. Using Firefox and RESTer
    2. Using cURL
  5. OTA Unlocking Problems
  6. Tasmota Configuration
  7. Conclusion

Some Preliminaries toc

I will not go into much detail about some of the preliminary steps performed before creating the needed Wi-Fi access point.

  1. Obtain the desired firmware. I compiled a modified version of Tasmota which I called sonoff_tweak.bin, but most seem to use sonoff-basic.bin.
  2. Install the HTTP server. This is only necessary if no HTTP server is available on the local area network. As mentioned before, my home automation host is already set up to do this, but to be thoroughly test different scenarios, I installed an HTTP server on my Ubuntu. I used the synaptic packet manager to get nginx-light which worked without any configuration. For some reason, no version of Nginx could be found in the Gnome Software yet it was easily found in Mint 19.
  3. Copy the Tasmota binary file to the /var/www/html directory. Do this as root using the sudo prefix. I installed the file in a sub directory called sonoff.
    michel@hp:~$ sudo mkdir /var/www/html/sonoff michel@hp:~$ sudo cp sonoff/sonoff_tweak.bin /var/www/html/sonoff

Create a Wi-Fi Access Point toc

The first major step is to create a Wi-Fi access point (AP) with the DIY mode required credentials. In what follows, the wireless network already in place is named HomeNet. It is connected to the local area network on subnet This pre-existing network is identified by the blue Wi-Fi icons in the figures below. Machines on that network have access to the Internet through the ISP provided router. The sonoffDiy Wi-Fi access point that will be created is tagged with red Wi-Fi icons.

The length of this section may look daunting, but that is only because four different ways of setting up an access point are described. The reader should keep in mind that only one of these approaches needs to be followed. Actually, there are probably other ways of going about this.

Since any device connected to the sonoffDiy wireless network has access to the local network (except for the guest network) and the Internet, I make sure that the sonoffDiy network is active only when flashing the firmware of a Sonoff device.

With a Desktop Hotspot toc

This may be the simplest approach and it will be used by most. It involves creating the needed access point with the Wi-Fi adapter of a desktop or portable computer which has access to the Internet using a wired (Ethernet) interface. An HTTP server on that same machine will download the firmware to the Sonoff. Alternatively, another HTTP server on the local area network could be used.

Unfortunately, an access point (hot spot) could not be created on my desktop computer as will be explained below. However, a hot spot could be set up on an older Toshiba Portégé running Ubuntu 18.04 to verify that this configuration does work.

Start by defining a hotspot connection using the NetManager connection editor.

michel@hp:~$ nm-connection-editor

The editor starts with a list of known network connections. Click on the + button at the bottom to create a new definition.

Choose Wi-Fi for the connection type.

  1. Name the connection.
  2. Enter the needed network name (SSID): sonoffDiy
  3. Set the Mode to Hotspot

  1. Click on the Wi-Fi Security tab.
  2. Select WPA & WPA2 Personal encryption protocols.
  3. Set the password to 20170618sn.
  4. Click on the Save button.

The previous steps need to be done once. Henceforth, start the access point by going to Wi-Fi settings.

  1. Click on the system menu in the top right hand corner of the screen.
  2. Click on the Settings icon.

This should display the Wi-Fi settings. If not, navigate to it.

If the Wi-Fi interface is not available, activate it by clicking on the white and grey slide button on the title bar. Wi-Fi should be ON as shown below.

  1. Click on the hamburger menu icon.
  2. Click on Connect to Hidden Network... Do not click on Turn On Wi-Fi Hotspot.. because this will start an ad-hoc Wi-Fi network with a network name set to the computer hostname.

  1. Select the connection defined in the previous step, sonoffDiy_AP.
  2. Click on the Connect button.

The connection to the HomeNet Wi-Fi network will be lost because the radio is now used to operate the sonoffDiy network. However, the connection to the local area network and hence to the Internet is preserved with the wired (Ethernet) connection.

Be warned, this may not work. I found that I could go through all the steps described above to create the sonoffDiy hot spot on my desktop machine, but the network would not come on line. A search yielded some helpful information. Running the suggested command showed that AP (access point) mode was not supported by either the Wi-Fi card or the Linux driver for that device.

michel@hp:~$ iw list Wiphy phy0 max # scan SSIDs: 1 ... Supported interface modes: * IBSS * managed ...

That is when I checked my rather old portable and found * AP among the modes supported by its Wi-Fi card. Using that machine, it was possible to create the desired Wi-Fi hotpoint with it and use it to update the ITEAD firmware and then replace it with Tasmota as explained below.

With a Guest Network toc

The Hitron cable modem supplied by my Internet service provider can be used to create a guest network. By setting the credentials to the values needed by the Sonoff in DIY mode and logging onto that network with the desktop computer and Android tablet, it should have been possible to update the ITEAD firmware and then replace it with Tasmota.

Here is how to set up a guest network on the Hitron modem.

With other modem that have that capability, the steps involved would probably be similar to those shown above. Rather disconcertingly, clicking on the Save Changes button results in a error message as can be seen below on the image on the left.

Yet, sonoffDiy does appear as an open unsecured network with a captive portal where it will be necessary to enter the network password.

I was able to connect to this guest network with my Linux desktop computer and the Sonoff switch was also able to connect to the guest network when in Diy Mode. With both the desktop and Sonoff connected to this hot spot, I was able to toggle the Sonoff relay off and on and get the device status as explained below without problems. Since the guest network provides access to the Internet, I presume that it would be possible to update the ITEAD firmware using the eWeLink application and then unlock the Sonoff and perform over-the-air updates. However a guest network of this type does not give access to devices on the local area network. Even if the desktop were connected by Ethernet to the LAN and if that connection were shared with others, access to the LAN (subnet from the guest network (subnet is not possible. Therefore, it would be necessary to have a Web server running on the desktop to make the firmware file available.

Unfortunately, my Android tablet cannot connect to the hotspot. I get the following error after entering the password "only allow DHCP client to use this wireless". This appears to be a bug in the Hitron modem firmware (based on a message on my ISP forum with regards to a different Hitron modem). If you are in a similar bind, it would be necessary to upgrade the ITEAD firmware of the Sonoff device before creating the hotspot.

With an OpenWrt Wi-Fi Router toc

This is the technique used to flash Tasmota on a Sonoff Basic R3. It is similar to using a guest network except that an old Rosewill RNX-N300RT Wi-Fi router is used to create the sonoffDiy hot spot. The router (a rebadged TP-Link TL-WR841N/ND v7) firmware was replaced with OpenWrt version 17.01 quite some time ago. A newer version of OpenWrt exists but it cannot be installed comfortably on a system with only 4 MB of flash memory and 32 MB of RAM.

Setting up the wireless access point with the Rosewill/OpenWrt router is a two-stage operation. First the Rosewill router has to be connected to the existing home network. In the second stage, the Wi-Fi interface has to be created.

The guide to setting up connecting the router to the LAN is a page from the OpenWrt user guide: Client Device - Connecting to an existing network. I will repeat the instructions somewhat edited here:

  1. Backup the current configuration just in case the Rosewill router needs to be used as before.
    • Click on SystemBackup / Flash Firmware.
    • In the Flash Operation / Actions tab, click on Generate archive button.
    • Save the configuration archive to a reasonable directory on the desktop computer.
    This is an optional but recommended step.
  2. Click on NetworkInterfaces, then click on the Edit button of the LAN Network.
  3. In General Setup tab, in Protocol, select Static Address.
  4. In IPv4 address write the new static address of this device. I chose which was not used by other devices. Adjust this IP address to correspond to your situation.
  5. In IPv4 Netmask set the netmask to
  6. In IPv4 gateway set the address of the gateway:
  7. In Custom DNS field set the address of the default gateway:
  8. Scroll down and in DHCP Server, in General tab, select Disable DHCP for this interface, to disable automatic IP assignment on the LAN. Client devices will be connected to a network where there is a router doing DHCP server already and this will avoid conflicts with it.
  9. Click on Save & Apply button at the end of the page. This will change the network configuration of the device.

Since the router is being connected to the existing network, there must be an Ethernet cable between it and the local area network as shown in the figure above. It is important that the Ethernet cable from the LAN router be connected into one of the four yellow LAN ports of the Rosewill router and not its blue WAN port. It may be necessary to power cycle the Rosewill router but after that it will be reached at from any computer on the LAN.

The guide to setting up the Wi-Fi access point is a page from the OpenWrt quick start guide: Enabling a Wi-Fi access point on OpenWrt. I will repeat the instructions somewhat edited here:

  1. Go to NetworkWireless. A Wi-Fi network can be created by clicking Add or if one already exists it can be modified by clicking Edit.
  2. Go to the Device Configuration and open the tab Advanced Settings: in the Country Code field, select the correct county code.
  3. In the tab General Setup, set ESSID to sonoffDiy.
  4. In the tab General Setup, uncheck all Network(s).
  5. In the tab Wireless Security, set the Encryption method to “WPA2-PSK”, recommended for home/small office networks.
  6. In the tab Wireless Security, set Key to 20170618sn
  7. Click on Save & Apply button at the end of the page. This will change the network configuration of the device.

The sonoffDiy Wi-Fi network will now be active. Any device that connects to that wireless network will have access to the Internet and to all resources on the local area network

The figure shows that a Raspberry Pi is used to serve the Tasmota firmware to the Sonoff. Of course that is not necessary and the desktop could perform that task as explained before.

With a Network Extender toc

The following image shows the hardware I used the first time I flashed Tasmota on a Sonoff Mini. My initial goal was to make the Python scripts used by Sonoff_Devices_DIY_Tools work in Linux as explained by ThierryM / Lo Furòl.

The wired LAN is extended with MoCA technology which uses coaxial cabling for television. The ActionTec WCB3000 which is at the far end of the cable provides both Ethernet and Wi-Fi connections. The extender has two radios (2.4 GHz and 5 GHz) that by default are enabled. Being surplus to requirements, both were disabled. It was very easy to activate the 2.4 GHz radio creating the needed Wi-Fi access point with the specific credentials required by the Sonoff DIY mode.

It is necessary to log onto the device. Here are the instructions pulled from WCB3000N_Wireless_Settings_Guide.pdf.

Open a web browser on the computer and enter http://wecb-XXXX.local in the address bar, where XXXX stands for the last four digits of the Extender’s serial number. The serial number can be found on the label located on the back panel of the Extender.

Just a warning, that method works very well in Linux if avahi is installed and should work in Mac OS where Bonjour is Apple's implementation of Zero Configuration Networking (zeroconf). There is a good chance that it will work in Windows especially if networked printing is enabled in the system. But even when zeroconf is implemented, some web browsers, Chromium notably, will not resolve a machinename.local URL.

Once logged in to the extender's web configuration utility,

  1. Click on the Wireless Setup icon.
  2. Select Basic Setup in the Wireless Settings menu.
  3. Select the 2.4Ghz radio (the ESP8266 in the Sonoff only works at that frequency).
  4. Enable the radio.
  5. Enter sonoffDiy in the Wireless Network Name field.
  6. Enter 20170618sn in the Password Phrase field.
  7. Click on the Apply button.

That is it; after 20 seconds the wireless access point is operating.

To be fair, MoCA is not a widely used technology, but in my case it was the simplest method available to flash Tasmota on DIY mode capable Sonoff switches. Its main advantage was that no changes to any other device on the LAN was needed.

Update the Sonoff Device toc

The newly received Sonoff Mini and Sonoff Basic R3 came with version 3.0.0 of the ITEAD firmware. I tried to use them in DIY mode but that did not work. As the DIY Mode API documentation states, version 3.3.0 of the ITEAD firmware is required. The upgrade can be performed with the eWeLink application from Google Play on an Android tablet or phone. There is an IOS version of the application.

Obviously, the Sonoff device must be powered up. The tablet is connected to the sonoffDiy network for this operation so that the credentials of the permanent HomeNet Wi-Fi network were not divulged. Details on how to do this may be forthcoming in a future revision of this post.

Upload Tasmota to the Sonoff Device toc

To put the device in DIY mode, it is necessary to unplug it, to open it and to place the supplied jumper on the two pins of the connector intended for that purpose.

The easiest way to open the Sonoff Mini is to press firmly with the thumb on the side of the cover between the front and the antenna wire while pulling the cover away from the base. See the picture on the left. The pins that need to be shorted with the jumper are visible in the figure on the right.

On a Sonoff Basic R3 it will be necessary to remove the two screws fastening the inner shell to the bottom plate. Then the jumper can be installed across the two pins on the top printed circuit board across from the switch.

Reconnect the Sonoff while observing the blue LED. At first it should flash briefly once a second. After a few seconds, the LED flashes twice every second indicating that the module is connected to the sonoffDiy network.

When doing this with a Sonoff Basic R3, the LED changed to a steady blue light. It was possible to ping the device and to discover it with avahi-browse as explained next. However, it was impossible to use the RESTful API to get information from the Sonoff, or set the relay, let alone update the firmware. When I unplugged the Sonoff and powered it back up, the same result obtained. When I unplugged the Sonoff, restarted the sonoffDiy Wi-Fi access point and then powered on the Sonoff, its LED started to flash twice every second and everything worked correctly thereafter. Perhaps the long period without power to the Sonoff was more important, and restarting the Wi-Fi AP was superfluous.

As soon as the Sonoff is connected you can get its coordinates using a Linux desktop computer running avahi.

michel@hp:~$ avahi-browse -t _ewelink._tcp --resolve + wlp3s0 IPv4 eWeLink_10009abcde _ewelink._tcp local = wlp3s0 IPv4 eWeLink_10009abcde _ewelink._tcp local hostname = [eWeLink_10009abcde.local] address = [] port = [8081] txt = ["data1={"switch":"off","startup":"off","pulse":"off","pulseWidth":500,"rssi":-47}" "seq=1" "apivers=1" "type=diy_plug" "id=1000983386" "txtvers=1"]

The parameters in bold are the data needed to use the DIY mode REST API. Only the wireless interface of the desktop was active, the wired interface was disabled. Some think that it can be difficult to locate the Sonoff device with avahi when more than one interface is active. I did notice that the module is rarely displayed with the command avahi-browse --all.

Following Michael Ingraham (Manual Flash), here is how to get the same information in a terminal window in MacOS.

MacBook-Air-de-Mme:~ mme$ dns-sd -B _ewelink._tcp Browsing for _ewelink._tcp DATE: ---Sat 28 Sep 2019--- 13:59:15.223 ...STARTING... Timestamp A/R Flags if Domain Service Type Instance Name 13:59:15.507 Add 2 5 local. _ewelink._tcp. eWeLink_10009abcde ^C (i.e. press CtrlC to exit. MacBook-Air-de-Mme:~ mme$ dns-sd -q eWeLink_10009abcde.local DATE: ---Sat 28 Sep 2019--- 13:59:54.177 ...STARTING... Timestamp A/R Flags if Name Type Class Rdata 13:59:54.178 Add 2 5 eWeLink_10009abcde.local. Addr IN

Now it's just a matter of sending HTTP requests with the POST method. This can be done with a Web browser or with the command line utility cURL as shown below.

Using Firefox and RESTer toc

I installed the RESTer extension by Jan in Firefox. Other extensions can do the same thing and the equivalent can be found for other browsers.

The REST API can be tested by closing the Sonoff relay.

Turning the switch on

  1. Start the RESTer extension by clicking on its icon in Firefox.
  2. Choose the POST method.
  3. Enter the address. Do not forget to adjust the IP address according to the information obtained with avahi-browse.
  4. Add the Content-Type variable in the HEADERS section.
  5. Set the value of the added variable to application/json. This and the previous step are optional.

  1. Select the BODY tab.
  2. Enter the request data:
      "deviceid": "10009abcde", 
      "data": {
          "switch": "on" 
  3. Click on the vertical three dots to display a menu about the format of the data.
  4. Ensure that JSON is checked.
  5. At last, click on the SEND button.

If everything works correctly, the response will be 200 OK and the JSON formatted result will be:

    "seq": 1,
    "error": 0

The red LED should come on indicating that the relay is closed.

It takes a minimum of two queries to upload the firmware.

Unlocking the wireless update mechanism

The first query unblocks the wireless update mechanism. Change the URL to (step 3) and enter the following values:

  "deviceid": "10009abcde", 
  "data": {} 

using the correct Sonoff identity (step 7). After clicking on SEND (step 9) almost the same response is obtained: 200 OK and

    "seq": 2,
    "error": 0


The third optional query verifies that the Sonoff can be flashed. The URL must be changed to (step 3) without request values except for the device id (step 7).

  "deviceid": "10009abcde", 
  "data": {}    

Clicking on SEND (step 9) should elicit an unusually long response.

    "seq": 3,
    "error": 0,
    "data": "{\"switch\":\"on\",\"startup\":\"off\",\"pulse\":\"off\",\"pulseWidth\":500,\"ssid\":\"sonoffDiy\",\"otaUnlock\":true}"

Cleaning up the sequences and reformatting the data payload yields the following JSON entity

"data": "{

which confirms that the switch is on and that over-the-air flashing is not disabled. Of course it is not necessary that the switch be on to flash the firmware.

Flashing the firmware

The last query tells the Sonoff where to get the firmware. The URL must be changed to (step 3) and the request values are also different (step 7).

  "deviceid": "10009abcde", 
  "data": {
    	"downloadUrl": "", 
    	"sha256sum": "bcdef54eab28bd918321c5ef1837fc8247238a9aa4ad738f9f393bca1234def8"

Obviously, it will be necessary to adjust the URL of the new firmware file and its SHA 256 checksum must be calculated. I do not know if it is verified or not because the value given was correct. Note that the binary file cannot exceed 508 KB. The file sonoff_tweak.bin is a customized version of Tasmota that works with the five types of devices I use in the house. The SHA 256 checksum was calculated with Double Commander, but it can also be calculated with a command line utility.

pi@raspberrypi:/var/www/html/sonoff $ shasum -a 256 sonoff_tweak.bin bcdef54eab28bd918321c5ef1837fc8247238a9aa4ad738f9f393bca1234def8 sonoff_tweak.bin

Even before flashing starts, the immediate response is 200 OK and {"seq": 4, "error": 0} which only means that the Sonoff received the command and that it will attempt to load the firmware. See SONOFF DIY MODE API PROTOCOL about possible error codes.

The actual download of the firmware will take some time. The blue Sonoff LED turns on and off more or less randomly during the binary file transfer. Then the red LED goes out while the Sonoff is reset and the relay is open. After barely a minute or two, both LEDs go out and the Sonoff with its new firmware is now functional. On my network the same IP address will be assigned when it reconnects to the wireless network. It is therefore easy to reach the wireless device web page.

Using cURL toc

Michael Ingraham posted a description on how to Manual[ly] Flash a Sonoff device in DIY mode two days before the first version of this note even appeared. He uses the command line utility cURL to send the HTTP request to the device. This is what RESTer ultimately does. Indeed the curl command it sends can be seen by clicking on the 3 vertical dot icon in the top right of the window.

In the spirit of Michael Ingraham's Wiki page, here are the four commands described above.

Turning the switch on

michel@hp:~$ curl \ > -d '{"deviceid":"10009abcde","data":{"switch":"on"}}' {"seq":1,"error":0}

Unlocking the wireless update mechanism

michel@hp:~$ curl \ > -d '{"deviceid":"10009abcde","data":{}}' {"seq":2, "error": 0}


michel@hp:~$ curl \ > -d '{"deviceid":"10009abcde","data":{}}' {"seq":3,"error":0,"data":"{\"switch\":\"off\",\"startup\":\"off\",\"pulse\":\"off\",\"pulseWidth\":500,\"ssid\":\"sonoffDiy\",\"otaUnlock\":true}"}

Flashing the firmware

michel@hp:~$ curl \ > -d '{"deviceid":"10009abcde","data": { \ > "downloadUrl": "", \ > "sha256sum": "bcdef54eab28bd918321c5ef1837fc8247238a9aa4ad738f9f393bca1234def8" }}' {"seq": 4, "error": 0}

Of course the IP address of the Sonoff and its deviceid must be changed to correspond to the device being flashed. Similarly the URL for the new firmware and its SHA 256 checksum must be set properly.

OTA Unlocking Problems toc

A reader of the first version of this post wrote that OTA unlocking did not work even though he had been able to toggle the relay using the DIY Mode API. Unable to replicate the problem, I was unfortunately not very helpful. Since then, I have come up against the same problem, albeit in unusual circumstances.

After pressing the SEND button in an ota_unlock request, that button gets replaced with a ABORT button and then nothing happens. After quite a while ("like forever!" to quote a teenager), an unhelpful message pops up which says that this problem should not have occurred.

Reading the relevant section of the SONOFF DIY MODE API PROTOCOL document gives some clues.

The following failure codes are added to the error field of the response body:

- 500: The operation failed and the device has errors. For example, the device ID or API Key error which is not authenticated by the vendor's OTA unlock service;

- 503: The operation failed and the device is not able to request the vendor's OTA unlock service. For example, the device is not connected to WiFi, the device is not connected to the Internet, the manufacturer's OTA unlock service is down, etc.

The reader's problem could very well have been that the Sonoff did not have access to the Internet or that an ITEAD server was down at that time. The switch, information and, I suspect, the OTA flash APIs are all local operations which would explain why he was able to toggle the relay. If I interpret the above correctly, OTA unlocking requires a connection to an ITEAD server <insert expletives of choice here>.

If the OTA unlock service is not on line, then it makes some sense that a 503 error was not reported and the HTTP request simply timed out. I am pretty sure that my particular failure was related to what is described under error code 500, yet the request timed out and the error code was not received.

After updating the ITEAD firmware to version 3.3.0, I backed it up. It was possible to then install Tasmota as described above.That backup was done in order to be able to restore that firmware to do more experiments. At some point,the ESP8285 flash memory was completely erased and then flashed Tasmota with esptool again and so on. When the ITEAD firmware was restored (each device has a unique version of the firmware, so the backed-up version can be meaningfully restored to only one device), the device could be controlled with the eWeLink application. It could also be deleted and paired again with the application without problems. But no attempt at unlocking OTA updates would work over a couple of days. Was it because the API Key, whatever that is, was wiped?

A couple of lessons can be drawn from this experiment gone awry. First, try backing up the ITEAD firmware after unlocking OTA updating. Secondly, use a Sonoff Basic R3 for this type of investigation. Decent firmware can always be flashed with a classic USB adapter with ease on that device.

Tasmota Configuration toc

Even though the HomeNet network credentials were inserted in the configuration file of the tweaked version of Tasmota that I had created, the Sonoff device will log on to the sonoffDiy network. Performing a reset 5 in the console, as recommended by Michael Ingraham, will remove the credentials for that network.

Of course a "friendly name" such as Wardrobe will not be displayed by a freshly installed Tasmota. I forgot to take screen shots at the appropriate time.

While in the console, I completed the switch configuration with a backlog command which aggregates any number of individual commands.

Backlog module 1; GPIO4 9; SwitchMode 3; PulseTime 400; SetOption55 1; Hostname garde-robe; Topic garde-robe; FriendlyName garde-robe

Explanations for these commands can be found on the Commands page on the Tasmota Wiki. The more important commands are as follows

There remained the problem of the physical push button. I wanted something that fitted in with the Decora style switches used in the house, but everything seemed very expensive. Luckily, Fond4 Technology has a YouTube video (Decora Style paddle switch conversion to momentary button action) on the subject. Although he transformed a Cooper switch, the technique worked with the Leviton switches that I can get at the nearby hardware store. So now we have a modified Decora style switch connected to a Sonoff Mini that just fits behind it in the wall box. This combination replaced a timer switch shown on the right whose tiny tactile push button had just become defective. A Sonoff Mini and a Decora switch cost less than a replacement wall timer switch, and the UAF (User Approval Factor as opposed to the WAF because I include myself in the category) is higher.

I "lost" a Sonoff after flashing. Keeping the Sonoff button pressed for 40 seconds gave the same result as entering the reset 5 command in the console. The Sonoff connected to the default HomeNet access point after that hardware reset.

Conclusion toc

What can be done if you do not have a Windows computer and do not have the hardware to create a Wi-Fi hot spot as described above? One could always rename the household wireless LAN and change its password during the time it takes to change the firmware. I think that should work, but it is not very practical if others are using the network to access the Internet.

When all else fails, the device could be flashed with a USB adapter. This is relatively easy with the Sonoff Basic R3, but in the case of the Sonoff Mini, dexterous use of a soldering iron will be required. It can be done according the YouTube videos by Andreas Spiess Tutorial Sonoff Mini (incl. DIY Mode and how to Flash Tasmota), 3D Jig for Flashing the Sonoff Mini (Quickie) and Dr Zzs Sonoff Mini Finally! The Smart Switch we've been waiting for! w/Tasmota for Home Assistant esphome. I recommend viewing these videos, especially the first one by Andreas Spiess which showed how to use the DIY mode REST API. It was while seeing that video a second time that the penny dropped and I realized it would be possible to use that API to flash the device.

Perhaps the author of Sonoff_Devices_DIY_Tools will modify the Python scripts so that we can use them in Linux. See his response to ThierryM in Impossible (but near) to flash firmware using DIY Tools under Ubuntu 18.04 #21.

Finally, I recommend that the Wiki page Sonoff DIY by Michael Ingraham be read in its entirety. It will be quite useful for owners of Apple systems, but everyone will benefit from consulting the page, especially if a stock Tasmota firmware binary is being used. Heed his advice, "Do NOT use the sonoff-minimal pre-compiled binary as it does not allow you to change any settings". I trashed a Wi-Fi Tuya based plug by flashing that binary.