I was looking for how to convert my Shelly 1 PM Mini Gen 3 and Shelly PM Mini Gen 3’s to ESPHome but I didn’t find a lot of information except for some posts that made it seem like you’d lose OTA functionality by doing it. So I used the information I could find and put this together for anyone else who’s trying to do the same. I successfully flashed 1x Shelly 1 PM Mini Gen 3 and 2x Shelly PM Mini Gen 3 and am able to push OTA updates from ESPHome so it seems like they’re working just fine.
Disclaimer, I only tried this on the 2 devices I listed above so I’m not 100% sure how it will be for other Shelly devices. I also bricked a PM Mini trying to do this because I messed up the partition table update. So be careful and double check what you’re doing.
Here’s where I collected information from, I couldn’t have done it without these posts:
https:// community.home-assistant .io/t/shelly-esphome-ota-conversion-guide/794350
https:// github .com/esphome/esphome/pull/5535#issuecomment-2801352955
https:// github .com/esphome/esphome/pull/5535#issuecomment-2801352955
https:// www.cellos .blog/fixing-connection-issues-by-flashing-esphome-on-shellys-ota/
(I’m only allowed to post 2 links so I had to break those up like that.)
Overview
Basically we’re setting up a fork of ESPHome to be able to update the partition table OTA. Then we’re flashing Shelly convert to Tasmota, GitHub - tasmota/mgos32-to-tasmota32: ESP32 Mongoose OS to Tasmota32 OTA updates for Shelly, updating the partition layout, flashing a basic ESPHome bin file that we create with the fork, updating the partitions again, and then flashing our final ESPHome bin file that will let us use it with your regular ESPHome.
Configure the ESPHome branch
- All of the below is done from a linux computer
git clone https://github.com/angelnu/esphome-1.git --branch=extend_ota
cd esphome-1
pipenv install
pipenv shell
cd esphome-1
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 setup.py install
- In the esphome-1 folder create test.yaml
- Example for Shelly 1 PM Mini Gen 3:
esphome:
name: test
platformio_options:
board_build.flash_mode: dio
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
platform_version: 6.4.0
version: 5.1.1
variant: esp32c3
wifi:
networks:
- ssid: "NETWORK"
password: "PASSWORD"
ota:
password: "OTAPASSWORD"
unprotected_writes: True
logger:
hardware_uart: USB_SERIAL_JTAG
web_server:
button:
- platform: restart
name: Restart
- Just create something for your OTA Password, it can be anything
- Make sure to set your network ssid and password
- Edit your hosts file,
/etc/hosts
, and set the IP for your Shelly to be test.local python -m esphome compile test.yaml
- Make sure it compiles without issue
- Keep this terminal window open, we’ll be using it later.
Flash the Shelly with Tasmota
- Download the appropriate release from Releases · tasmota/mgos32-to-tasmota32 · GitHub
- Go to the Shelly’s webpage and flash the file downloaded above
- Once flashed, connect to the Tasmota AP and add to your wifi
- Once on the network, go to its webpage from your computer
- Click on Configuration > Auto-configuration, and select the model you’re flashing, then hit apply
- Once it reboots go to Consoles > Partition Wizard and click Start migration
- Once it reboots go to Tools > Partition Wizard and click Resize FS to max
- Once it reboots go to Tools > Console > type
SetOption78 1
and press enter - You should see
RESULT = {"SetOption78":"ON"}
- Go to Firmware Upgrade > Choose file, and browse to the esphome bin we created earlier, it’s under the esphome-1 directory and then .esphome/build/test/.pioenvs/test/firmware.bin
- Select and then Start upgrade
- You should see Upload Successful and then the page will refresh and you’ll see the esphome webpage
- In the terminal we used earlier run
python -m esphome -v upload-factory-ota test.yaml
Home Assistant ESPHome Config
- Look up the ESPHome config template for your device and use that to create a minimal config in your ESPHome
- Just keep the basics for now, esphome, esp32, api, ota, wifi, captive_portal, we’ll add the rest later
- Install > Manual download > OTA format (Previously Legacy)
- Move the downloaded file to your esphome-1 folder
- In the same terminal as before run:
python -m esphome -v upload test.yaml --file “new esphome”.bin
- If all was successful if should be discovered by Home Assistant and it will show online in ESPHome so you can now update the config and push an OTA update.