Skip to content

Instantly share code, notes, and snippets.

@rradillen
Created August 18, 2020 15:01
Show Gist options
  • Save rradillen/8dd0e8a680ce80d0a35f1185de7b432a to your computer and use it in GitHub Desktop.
Save rradillen/8dd0e8a680ce80d0a35f1185de7b432a to your computer and use it in GitHub Desktop.
Shelly transparent ota updates in firewalled network.

Prerequisites

  • Being able to create arbitrary A records in your local dns server
  • Run your own webserver that is accessible to the shellies.
  • Run a cron job on the webserver host
  • Curl, JQ and sed.
  • Don't use the shelly cloud

General strategy

I exploit the fact that Shelly's OTA mechanism uses http instead of https to fetch updates. I have my webserver fetch the firmware itself and store it in the folder structure as on api.shelly.cloud. I then have my dns tell the Shellies that my webserver is api.shelly.cloud.

Step 1: Manifest

On your webserver fetch the file https://api.shelly.cloud/files/firmware and store it in /files/firmware. This should make sure the file is served on /files/firmware.

Step 2: Files

On your directory create a subdir named firmware. In that directory run the following one liner.

curl 'https://api.shelly.cloud/files/firmware' | jq '.data[].url' | sed 's/http/https/g' | xargs -n 1 wget

This should download the all the firmwares for the different devices.

Step 3: DNS

On your local DNS server make sure that api.shelly.cloud points to your local web server. Make sure that your webserver itself doesn't use that record too.

Step 4: Automate

Add a cron job that runs step 1 and 2 periodically.

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