Skip to content

Instantly share code, notes, and snippets.

@oliverkurth
Last active December 28, 2022 22:44
Show Gist options
  • Save oliverkurth/ea7541d4c58eba496a6d163719a05570 to your computer and use it in GitHub Desktop.
Save oliverkurth/ea7541d4c58eba496a6d163719a05570 to your computer and use it in GitHub Desktop.

Instructions from https://tasmota.github.io/docs/Sonoff-DIY/ , but more unixy. Using additional information from https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/master/other/SONOFF%20DIY%20MODE%20Protocol%20Doc%20v1.4.md , especially for the ota_flash command.

Prerequesites: httpie (apt install httpie), docker. curl instead of httpie probably works too.

  • plug in device to power
  • press button for > 5 seconds (first attempt failed, worked after reconnecting)
  • connect to wifi itead_..., password 12345678 with a phone (remember to turn off cell data)
  • point browser on phone to 10.10.7.1 and configure your wifi
  • find IP address from dhcp leases file (or fing or whatever)
  • echo '{"data": {}}' | http -j post http://192.168.2.238:8081/zeroconf/info , and take note of the deviceid.
  • (if the command above fails with 'Connection reset by peer', unplug/plug the device and try again)
  • echo '{"data": {}}' | http -j post http://192.168.2.238:8081/zeroconf/ota_unlock
  • download tasmota-lite.bin from http://ota.tasmota.com/tasmota/ (image size needs to be < 500K, see itead/Sonoff_Devices_DIY_Tools#102)
  • calculate sha sum: sha256sum tasmota-lite.bin
  • start a web server: docker run -it --rm -p 8081:80 --name web -v $(pwd):/usr/share/nginx/html nginx
  • edit a file ota_flash.json, using the devicedid from the info command above:
{ 
	"deviceid": "1001xxx", 
	"data": {
    	"downloadUrl": "http://<ip of your web server>:8081/tasmota-lite.bin", 
    	"sha256sum": "5b6bdb20cd1badce1d1a95155e5e72bc92482df65c441fe013399495155fc1a5"
    } 
 }

  • cat ota_flash.json | http -j post http://192.168.2.238:8081/zeroconf/ota_flash

If you observe the console of your web server you will see tons of GET requests. At the end is a "POST /api/device/otaFlash HTTP/1.1" which will fail, but that doesn't matter. The device boots into Tasmota. It may recover the WiFi config and connect to it. If not, fnd the AP with your phone, configure like any other new Tasmota device.

@oliverkurth
Copy link
Author

Apparently, for the unlock to succeed the device needs a connection to the internet. If not, the request times out.

@oliverkurth
Copy link
Author

This works for the Sonoff Mini. It does not work for the plugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment