ESPHome changing node name

I’ve been working through an issue with changing the name of an ESPHome node.

Running 0.98.4 in a venv under Debian 9.9 on a pc.

I have a number of Brilliant smart switches - tuya based. They flash easily with tuya-convert.
I decided that I didn’t like the naming scheme that I was using so I removed all the integrations from HA and then re-flashed them with the new name using the “use_address:” directive in the yaml.
This worked fine (and I subsequently removed “use_address:” as per the instructions on ESPHome.)

Back in HA and they appeared under “Configuration/Discovered” with the new name. After clicking on the CONFIGURE button, HA eventually reported that is was unable to resolve the IP address and then offered the old name in the dialog.
But I’d removed all integrations using the old name??

So I removed the new integration again and starting looking around the .storage directory and noticed a large number of “esphome.xxxxxxxx” files which contained references to the old nodes.
Shut down HA, deleted all these files and restarted.

Same behaviour again. So this time, I ignored the auto-discovery and clicked on the “+” button and supplied the new name and it worked fine.
Head scratching - there are no references left (that I could find) in HA to the old name so where is HA getting it when I click on “CONFIGURE”? My router shows them with the new names.

Anyway, re-flashed a few more and just added them manually until I finally noticed…

After ESPHome flashed the new name and connected to dump the logs, I was just taking a quick glance to make sure the new name was appearing but initially failed to take note of the fact that the old name was listed under the “Over-The-Air Updates” and “API server” sections.
Looked back in the .yaml and definitely no reference to the old name. OK, I’ve removed the “use_address:” line - flash it again and see what happens.

This time, everything is fine.

I read the instructions in the ESPHome documentation again and it just reminds you to remove the “use_adress:” line for any future uploads - but it doesn’t say that you really need to flash the device twice to get completely rid of the old name.

Apologies if this is the intended behaviour and I’ve missed something but if not, it might be useful to someone.

1 Like

The use address seems like a bit hard, as I personally don’t use the dashboard and I go with command line it is easier as I can have any node configuration and put into any other node, you do that using the command:

esphome file_config.yaml run --upload-port <ip-address-of-node>

So of course you don’t have to upload twice.

Maybe a better UI approach will be a custom “run” button which allows you to choose the ip address one time, if you find that useful consider adding a feature request on the github.

Thanks

3 Likes

Thanks for the tip.

I use the command line as well as I don’t have a hassio dashboard - running HA in a venv.

I just tested and confirmed that using the “–upload-port” argument correctly sets the OTA and API values the first time.
I agree - it is much easier than editing the yaml twice.

Thanks again!