Update ESPHome node/s programmatically?

Is it possible to update selected ESPHome nodes programmatically?

I have a lot of nodes so have two choices:

  • update all, which makes it difficult to find a suitable time and seems to fail more often than not
  • update them manually, which is a real pain!

So what I’m envisaging is creating lists of nodes and automating their updates from a manual trigger. I have no idea if this is possible, hence the question! :slight_smile:

Thanks.

Richard

Thank you, @nickrout - I hadn’t found that so really appreciate it.

I’ll review in more detail after work this evening but one quick question now: where is the command line accessed from?

If you are running the addon, you need to access the docker container like this

docker exec -it addon_15ef4d2f_esphome /bin/bash

The name of the addon may be different, check with

docker ps|grep esphome

Thanks, @nickrout - that is helpful but unfortunately I don’t have the skills or confidence to start ‘playing’ with Docker. I was hoping for something within the Hass or ESPHome GUI.

Longer-term, I’ll set up a test HASS instance and experiment.

OK, so you can’t type? If you can post here, you can type a couple of commands.

Perhaps I’m not expressing myself or understanding clearly.

What I understand is that to work with ESPHome through the command line I would have to:

  1. enable the SSH & web terminal add-in on HASS (I have it installed but keep it disabled until needed)
  2. remove protection mode to allow access to Docker (that already makes me a bit nervous)
  3. connect to the terminal through the GUI
  4. run the docker commands

So far, so good. I’ve done all the above so know it works - but, as stated, am a bit nervous due to the privileged access it gives to the underlying Docker etc. and the knowledge that I don’t know much about how that all works so could break my instance of HASS.

Putting that aside, I can now run individual commands to update individual nodes but how would I automate this? I presume I’d have to create scripts of some type and run those? Do you have examples you can share, please?

One line from the directory with the yaml files in

for node in ls *.yaml; do esphome run --no-logs  $node; done

Thanks, @nickrout - I’m probably still missing something.

As I understand it, that line will step through all the nodes, updating them - which is pretty much the same as clicking ‘update all’ in the GUI.

To automate this to update only selected nodes will require amending that line to pull lists of those nodes from text files or similar.

Definitely food for thought and I’ll give it a go but do hope that the selective update is added to ESPHome soonest!

Yes you could make a text file (named, say, nodelist) of the ones you want to update

for node in cat nodelist; do esphome run --no-logs $node; done

Thanks - that helps a lot.

As I said earlier - I’m happy to learn and experiment but am very mindful that doing so on a production instance is not a great idea. It’s why I plan to set up a test / development box to play with.

Probably a good idea.