Restore switch to build_time_str in mqtt sw_version and version sensor

This commit is contained in:
David Woodhouse
2025-12-15 23:14:25 +00:00
parent a5ff374540
commit 4a58ab6310
2 changed files with 7 additions and 3 deletions
+3 -1
View File
@@ -154,7 +154,9 @@ bool MQTTComponent::send_discovery_() {
device_info[MQTT_DEVICE_MANUFACTURER] =
model == nullptr ? ESPHOME_PROJECT_NAME : std::string(ESPHOME_PROJECT_NAME, model - ESPHOME_PROJECT_NAME);
#else
device_info[MQTT_DEVICE_SW_VERSION] = ESPHOME_VERSION " (" + App.get_compilation_time_ref() + ")";
char build_time_str[App.BUILD_TIME_STR_SIZE];
App.get_build_time_string(build_time_str);
device_info[MQTT_DEVICE_SW_VERSION] = str_sprintf(ESPHOME_VERSION " (%s)", build_time_str);
device_info[MQTT_DEVICE_MODEL] = ESPHOME_BOARD;
#if defined(USE_ESP8266) || defined(USE_ESP32)
device_info[MQTT_DEVICE_MANUFACTURER] = "Espressif";
@@ -1,6 +1,6 @@
#include "version_text_sensor.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/core/log.h"
#include "esphome/core/version.h"
#include "esphome/core/helpers.h"
@@ -13,7 +13,9 @@ void VersionTextSensor::setup() {
if (this->hide_timestamp_) {
this->publish_state(ESPHOME_VERSION);
} else {
this->publish_state(str_sprintf(ESPHOME_VERSION " %s", App.get_compilation_time_ref().c_str()));
char build_time_str[esphome::Application::BUILD_TIME_STR_SIZE];
App.get_build_time_string(build_time_str);
this->publish_state(str_sprintf(ESPHOME_VERSION " %s", build_time_str));
}
}
float VersionTextSensor::get_setup_priority() const { return setup_priority::DATA; }