Possible to get ESPhome checking firmware URL and doing OTA?

Struggling to get some battery powered ESP8266 (Wemos D1) properly managed in my network. Since they are in deep sleep I have tried to follow the instructions on MQTT messaging to keep the nodes alive to perform OTA but no luck so far.
Are there are way to get the node to check an URL for an updated firmware and perform the OTA update with the firmware from that URL? Would be nice to have this done once a day for example.

I have monitoring of 10 beehives running on battery powered D1s waking up every 90 minutes to report temperature. Would be nice to have a way to flash them if needed without having to collect the boxes :slight_smile:

2 Likes

Some years laters …

I wrote an external component that is able to do so. It’s tested with esp32-arduino, but it might works for 8266:

external_components:
  - source: github://oarcher/piotech/


ota_http:


button:
  - platform: template
    name: "Firmware update"
    on_press:
      then:
        - ota_http.flash:
            url: http://example.com/firmware.bin
            verify_ssl: false
        - logger.log: "This message should be not displayed(reboot)"

For the moment, it’s mainly a test/draft, but i will work more of it in case of interest.

4 Likes

@oarcher, this is what I was looking for :smiley:
want to use this to remotely update devices that are outside the local network.

I will test and let you know if it works.

greetings
woojtekk

Hello, this is something i wasl looking for in those days, but when i compile i have this problem:

Compiling .pioenvs/00-esp8285-batt-test/src/esphome/components/output/float_output.cpp.o
Compiling .pioenvs/00-esp8285-batt-test/src/esphome/components/rtttl/rtttl.cpp.o
Compiling .pioenvs/00-esp8285-batt-test/src/esphome/components/sntp/sntp_component.cpp.o
src/esphome/components/ota_http/ota_http.cpp: In function ‘bool esphome::ota_http::http_connect(HTTPClient*, std::string)’:
src/esphome/components/ota_http/ota_http.cpp:63:23: error: ‘const class String’ has no member named ‘compare’; did you mean ‘compareTo’?
63 | bool secure_ = url_.compare(0, 6, “https:”) == 0;
| ^~~~~~~
| compareTo
src/esphome/components/ota_http/ota_http.cpp:68:28: error: ‘using element_type = class WiFiClient’ {aka ‘class WiFiClient’} has no member named ‘setInsecure’
68 | wifi_client_secure_->setInsecure();
| ^~~~~~~~~~~
src/esphome/components/ota_http/ota_http.cpp:69:28: error: ‘using element_type = class WiFiClient’ {aka ‘class WiFiClient’} has no member named ‘setBufferSizes’
69 | wifi_client_secure_->setBufferSizes(512, 512);
| ^~~~~~~~~~~~~~
src/esphome/components/ota_http/ota_http.cpp:86:18: error: ‘client’ was not declared in this scope; did you mean ‘client_’?
86 | begin_status = client->begin(*wifi_client_, url_);
| ^~~~~~
| client_
*** [.pioenvs/00-esp8285-batt-test/src/esphome/components/ota_http/ota_http.cpp.o] Error 1
========================= [FAILED] Took 107.86 seconds =========================

i am using esphome v2023.6.4, woojtekk did you tried it?, this is something it will be perfect for many users

Hi, I encountered the same problem as you did. The library mentioned in the article does not seem to support ESP8266. I tried using it with ESP8266 but was not successful.

oarcher this is absolutely amazing. I reeeeeeaaaaalllly need it :slight_smile: Any chance you can support esp-idf ? The devices I use need to have TLS as well, and as far as I am aware, the TLS support is only available for esp-idf.

1 Like

+1
really need here too

sorry for late replay. long holiday :wink:

I using ota_http on esp-01 and esp-d1 mini and it works perfectly.
Several of my devices work away from home using MQTT and a slow GPRS connection (mainly weather stations, irrigation monitoring and the like).
So far I have not had any problems.

greetings
woojtekk

Hi @oarcher
I tried your component and it throw the following error:

[21:38:09][D][button:010]: 'Firmware update' Pressed.
[21:38:09][D][esp32.preferences:114]: Saving 1 preferences to flash...
[21:38:09][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[21:38:09][D][ota_http:054]: Trying to connect to https://mywebpage.com.vn/firmwares/[mydeviceddns]/firmware.bin
[21:38:12][D][ota_http:101]: firmware is 1132272 bytes length.
[21:38:12][I][ota_http:111]: Progress: 0.1%
[21:38:12][E][ota_http:103]: Error code (131) writing binary data to flash at offset 4000 and size 1132272
[21:38:12][E][ota_http:150]: Abort OTA backend
[21:38:12][E][ota_http:153]: Abort http con
[21:38:12][E][ota_http:155]: previous safe mode didn't succed. ota_http skipped
[21:38:12][D][main:603]: This message should be not displayed(reboot)

My esphome configuration is here

ota_http:

button:
  - platform: template
    name: "Firmware update"
    on_press:
      then:
        - ota_http.flash:
            url: https://mywebpage.com.vn/firmwares/mydeviceddns/firmware.bin # revise it here
            verify_ssl: false
        - logger.log: "This message should be not displayed(reboot)"

Where does the problem occurred, please advise with thanks. (I doubt I used https, in fact I don’t have an http server)
Man thanks for your attention and support!

It looks like https://mywebpage.com… is just an example. You need to provide the http link you manage and where the OTA files will come from. Unless that is your web page and thats hilarious.

Hi,
I just removed the real web address and replace with this to avoid exposure to all on the working things!
But that was the response from log on the correct version.

[21:38:09][D][ota_http:054]: Trying to connect to https://mywebpage.com.vn/firmwares/[mydeviceddns]/firmware.bin
[21:38:12][D][ota_http:101]: firmware is 1132272 bytes length.

THe log show that firmware downloaded and have progress in updating but it failed!
Bests!
Ngoc