I would like use esphome to configure several devices, on different wifi networks, then use the http_request OTA platform to update them all at once. Is there a way to store things like the WiFi credentials and maybe some other site-specific configuration outside of the firmware, where it can be read at boot?
spiffs or littlefs would be the way, but I didn’t see any documentation on how to do that with esphome
esphome has a different model (individual binaries for each device). Tasmota has the model you want (one binary to rule them all) but it is very different.
yeah, I’m aware that I’m fighting esphome’s design here. I was hoping there had been some improvement in this area, since esphome has a really good model for everything else. Ideally I would be able to put my esphome yamls into a git repo, have CI build the binaries when the yamls change, then have the individual devices download the new version, with any secrets and device-specific stuff provisioned once on first install.
I was hoping the model had shifted to include this type of use case, since things like the http_request OTA option, the captive portal component and the Improv wifi stuff seem like they’re working toward this use case. Is this type of thing on a roadmap somewhere?
Ready made projects is the closest thing, but there is no documented way of creating your own.
I suspect this will be harder than you think, since it seems many esphome components are designed with compile time config in mind and probably don’t support run time changes. But, it will depend on what you need your devices to be able to do.
Note that if you use the wifi component without ANY credentials, you can then use captive portal to set them.
Subsequent OTA updates of the device will not overwrite the stored credentials.
interesting, the docs reference serial uploads overwriting those credentials, I don’t think I realized that meant OTA updates will NOT overwrite stored credentials. That’s most of what I need honestly. Would be nice if there was a way to ask the user for other inputs in the captive portal and store them in a way that could be retrieved with a lambda or something
Yeah I have tried various jiggery to achieve this - no success so far. I was looking at using the docker container linked below as a HA add-on and use it to store and retrieve json fields in files named based on the MAC address:
I just logged a feature request for global variables to survive an OTA update. Arduino can do this already using the eeprom.h library. It would provide some of the functionality that you need and I would use it too. Go to the discussion on GitHub and add your vote and any notes.
Ok - Currently - if you use captive portal and no wifi credentials, both wifi credentials set by captive portal and any globals with restore_value: true are preserved over an OTA flash.
I have asked the question can this be a documented behaviour, so that if it fails after some future update we can validly log a ticket…
What this means though is that currently, if you want config values (that can be set at runtime) and wifi saved when flashed over the air, a combination of captive portal and restored global variables can achieve that.