Read ESPHome compile-time version as sensor

Can an ESPHome built firmware find out which ESPHome version (like 2023.2.1) was used to compile it?

I’m not looking to read the current ESPHome version installed in HA but the version that was installed at compile time of the firmware.

My goal is to get an overview of the ESPHome versions that were active when any of my MCUs were last updated. The Update sensor of HA does not seem to do a good job for that. It already updates the version when a new compilation is started. This way I’ll never know, if the new firmware was really uploaded.

I saw a pr just a day or so ago to add this into the compile.

1 Like

Then again HA does already know because it is in the devices UI.

1 Like

Incredible!

Yes, and I guess I was wrong with my assumption that …
“The Update sensor of HA does not seem to do a good job for that.”.

In fact the update sensor seems to accurately read the firmware’s compile version!
It is only the “Update” button in the ESPHome section of HA’s frontend that is removed prematurely when new compile starts.

Weirdly I am not getting an update sensor

esphome-2023-3-0-dev
home assistant 2023.2.5

Do I need HAOS? I am on supervised.

In fact I am using HAOS. I get these sensors for all my ESPs for some months now. They all pop up whenever I install a new ESPHome version. Not exactly sure, when this started. But late last year the whole update sensor mechanics improved substantially.

What are these update entities named?

They are called “update.YOUR_NODE_NAME_firmware”.

Here is a whole bunch of mine because I just installed a new ESPHome version minutes ago.

image

image

I already use this for a long time to get an overview of the firmware versions.

And I made an overview page in HA showing this kind of information

1 Like

I just found that Version Text Sensor yesterday, and set it up on my devices. Here’s the section from one of my yaml files:

# Retrieve ESPHome version information
text_sensor:
  - platform: version
    name: "MyDevice ESPHome Version"
    id: my_device_version

Works great. You can of course break it out into two strings as above, but for me the one long string was sufficient.

Thanks @jsuanet, this is exactly what I was looking for!
I swear I checked the ESPHome website back and forth before posting. I don’t understand, why I did not find that sensor.

Not really sure what this means in the changelog

That’s OK, I’m not sure what these two mean, either:

Release 2023.2.1 - February 16

Release 2023.2.2 - February 17

I tried asking if there’s any way for someone not intimately familiar with the source code to get some kind of clue as to what’s changed and whether it affects us, but I sort of struck out.

My conclusion is, if my ESP devices are working, then I’ll wait to update them on the same schedule as I do for HA. I do that once a month, after the point updates have slowed down, usually around the third week of the month.

1 Like

Have a click on the pull request and read them. The first one (4443) says

This allows force cleaning and full recompile when updating ESPHome version.

The second one relates to the dashboard import so you really don’t need to worry unless you are creating a new device’s firmware.