Shelly with ESPHome: OTA Rollback to Shelly?

Just out of curiosity, why do you want to ho back from esphome to shelly native? Because I’m actually thinking about switching from native to esphome :sweat_smile:

If anybody else is wondering how to do this i just rolled 3 ESPHome Shelly 1 devices back to stock firmware.

Step 1:
Download the tasmota-lite.bin file

Step 2:
Enable web server on your esphome device, upload the tasmota-lite firmware.

Step 3:
Connect to the new Tasmota wifi device and set it up on your network

Step 4:
Find its ip adress, and then follow the rest of the steps from this guide (translate to english via google translate if needed)

4 Likes

Hello, thanks for the tip, I was able to return to the original firmware with all my shelly 1, and shelly 1Pm (I point out that you have to use the minimal pocket and not the light to have the space to then install the MGOS firmware.
However, I was unable to restore my Shelly Plus S sockets.
I freeze at the final stage. Installed MGOS firmware, but then when I try to install .zip shelly I get this error:


S.zip
is the correct firmware taken from here:
https://www.shelly-support.eu/filebase/index.php?filebase/123-shelly-plugs/

Thanks @fillwe. I was able to rollback Shelly EM from Tasmota to original firmware with this method :slight_smile:

1 Like

Hi I have a Shelly 1 flashed with ESPHome, but can’t connect to it (its offline). WHich are my options? I can continue woth ESPhome, instead of flashing back Shelly firmware (it seems difficult), but how to connect to Shelly1/esphome??

Is the fallback wifi hotspot enabled ?

WHich is?

This is the Yaml


esphome:

  name: thermostat_right

  platform: ESP8266

  board: esp01_1m

substitutions:

  # Modify variables based on your settings

  hostname: 'thermostat_right'

wifi:

  networks:

  - ssid: xxxx

    password: xxxxx

  manual_ip:

    static_ip: 192.168.1.162

    gateway: 192.168.1.1

    subnet: 255.255.255.0

# Enable logging

logger:

# Enable Home Assistant API

api:

ota:

web_server:

  port: 80

binary_sensor:

  - platform: status

    name: $hostname status

switch:

#################

#   14a pedonale

#################

  - platform: gpio

    pin:

      number: GPIO4

      inverted: no

    id: relay_pedonale14a

  - platform: template

    name: "cancello14a"

    icon: "mdi:gate"

    turn_on_action:

    - switch.turn_on: relay_pedonale14a

    turn_off_action:

    - switch.turn_off: relay_pedonale14a

 

  - platform: restart

    name: $hostname Restart

sensor:

  - platform: wifi_signal

    name: $hostname WiFi Signal

    update_interval: 60s

  - platform: uptime

    name: $hostname Uptime

    id: uptime_s

    update_interval: 15s

   

text_sensor:

  - platform: version

    name: $hostname ESPHome Version

  - platform: wifi_info

    ssid:

      name: $hostname WiFi

  - platform: template

    name: $hostname Uptime (formatted)

    lambda: |-

      uint32_t dur = id(uptime_s).state;

      int dys = 0;

      int hrs = 0;

      int mnts = 0;

      if (dur > 86399) {

        dys = trunc(dur / 86400);

        dur = dur - (dys * 86400);

      }

      if (dur > 3599) {

        hrs = trunc(dur / 3600);

        dur = dur - (hrs * 3600);

      }

      if (dur > 59) {

        mnts = trunc(dur / 60);

        dur = dur - (mnts * 60);

      }

      char buffer[17];

      sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);

      return {buffer};

    icon: mdi:clock-start

    update_interval: 15s

If the device has problems connecting to wifi it creates it’s own hotspot that can be connected to for reconfiguration.

Yours doesn’t have it configured.

How to did you originally flash it to esphome ?

I think your only option is to try flashing with a USB to serial converter.

Anyone has a tip with what serial flash software and (windows) and what file to use:
image

to flash back a shelly to original stock firmware?

(flashing via OTA) - the switch25.bin file, esphome gives me:
Update Failed: ERROR[4]: Not Enough Space

Via serial for both .bin files:

Using 'COM12' as serial port.
Connecting....
Detecting chip type... ESP8266
Connecting....

Chip Info:
 - Chip Family: ESP8266
 - Chip Model: ESP8266EX
 - Chip ID: 00B0A1C6
 - MAC Address: 84:CC:A8:B0:A1:C6
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
 - Flash Size: 2MB
Unexpected error: The firmware binary is invalid (magic byte=EA, should be E9)

It worked via this:
https://www.shelly-support.eu/forum/thread/8278-anleitung-ota-zu-original-zurück/?pageNo=1

did you try to gzip it first?

Warning: Flashing wrong firmware could brick your device.

Just in case anyone stumbled here intending to rollback a Shelly Gen2 (Esp32 based - plus series) device. The above logic might not work as it seems to be for ESP8266. Further Shelly does not seem to be providing Gen 2 devices firmware on their website yet.

So firstly, you need to get the firmware. For this I used the below project which provides links to latest firmware:

Afterwards, I downloaded mos tool (which is from mongoose os used by Shelly Gen2 for OTA, etc):
https://mongoose-os.com/docs/mongoose-os/quickstart/setup.md

And lastly, after attaching the USB serial adapter to Shelly hardware with GPIO0 set to Ground (ready for flashing) executed below command:
mos flash --esp-baud-rate 921600 Plus1PM.zip

That’s it the device booted with shelly firmware restored. I doubt that my power meter calibration, etc was restored. So in case you have not yet flashed original firmware, it would be best to take backup of the original firmware with all calibration files using the same mos tool before you venture into updating original Shelly firmware to tasmota or esphome.

Note: Change the filename to whats suitable for your device.

I have a bunch of Shelly 1’s on eBay. I tried to flash then to tasmoda and then ESPHome. I couldn’t figure out the flashing, so maybe one of you guys would like them. I hate to throw them out. Enjoy

  1. this is the easiest device to flash. All ports are open. ( google and you will find many tutorials )
  2. you don’t need to flash it if you want to take it off the cloud. Home Assistant has an integration without using the shelly cloud service.
  3. If you want to use MQTT then the Shelly One web interface has a tab to enter your MQTT info.
1 Like

indeed i stumbled in this thread, having a Shelly Gen2 “1pm plus” tasmota device and want to revert to stock firmware. i also have a second “1pm plus” still running at stock firmware for comparing both OS. So i wonder how you did the mentioned backup with mos tool, i did not find a corresponding parameter? i thought taking a backup of the stock device and restoring it on the tasmota one would be a good option or is there an option to re-calibrate a stock shelly device as you can to with tasmota?

Hey, is the firmware you linked original shelly? Seems to be Apple HomeKit

I think I looked into the source code of python file mentioned in " Reverting to stock firmware" section to get the firmware file url.

I ended up flashing shelly homekit and then used the revert function.

I could not find the firmware for Shelly UNI. Does anyone know why it is not on the list? At least it is not as Shelly UNI

Hey. Have you ever managed @Diegocampy? I am still getting the same error:

[I] ❰dan❙~/Downloads❱✘≻ curl -i -F filedata=@./SHRGBW2.zip http://10.42.42.44/update
HTTP/1.1 500 Internal Server Error
Server: Mongoose/6.18
Content-Type: text/plain
Connection: close

-12 Write failed

[I] ❰dan❙~/Downloads❱✔≻ curl -i -H "Content-Type:application/zip" -F filedata=@./SHRGBW2.zip http://10.42.42.44/update
curl: (56) Recv failure: Connection reset by peer