diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 5186e5afda..85f4566f3c 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1472,7 +1472,10 @@ bool APIConnection::send_device_info_response(const DeviceInfoRequest &msg) { resp.set_esphome_version(ESPHOME_VERSION_REF); - resp.set_compilation_time(App.get_compilation_time_ref()); + // Stack buffer for build time string + char build_time_str[Application::BUILD_TIME_STR_SIZE]; + App.get_build_time_string(build_time_str); + resp.set_compilation_time(StringRef(build_time_str)); // Manufacturer string - define once, handle ESP8266 PROGMEM separately #if defined(USE_ESP8266) || defined(USE_ESP32) diff --git a/esphome/core/build_info_data.h b/esphome/core/build_info_data.h index 81c24e0fb5..5e424ffaca 100644 --- a/esphome/core/build_info_data.h +++ b/esphome/core/build_info_data.h @@ -7,4 +7,4 @@ #define ESPHOME_CONFIG_HASH 0x12345678U // NOLINT #define ESPHOME_BUILD_TIME 1700000000 // NOLINT -static const char ESPHOME_BUILD_TIME_STR[] = "Jan 01 2024, 00:00:00"; +static const char ESPHOME_BUILD_TIME_STR[] = "2024-01-01 00:00:00 +0000"; diff --git a/tests/integration/test_build_info.py b/tests/integration/test_build_info.py index c1c655c664..7079594471 100644 --- a/tests/integration/test_build_info.py +++ b/tests/integration/test_build_info.py @@ -26,7 +26,7 @@ async def test_build_info( assert device_info.name == "build-info-test" # Verify compilation_time from device_info is present and parseable - # The format is "Mon DD YYYY, HH:MM:SS" (e.g., "Dec 13 2024, 15:30:00") + # The format is ISO 8601 with timezone: "YYYY-MM-DD HH:MM:SS +ZZZZ" compilation_time = device_info.compilation_time assert compilation_time is not None