From 28f30c990e4b7e15a423aaf6bc88708a6a787ab0 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 26 May 2026 23:56:41 -0500 Subject: [PATCH] revert --- esphome/components/api/api.proto | 2 +- esphome/components/api/api_connection.cpp | 2 ++ esphome/components/api/api_pb2.cpp | 4 ++++ esphome/components/api/api_pb2.h | 3 ++- esphome/components/api/api_pb2_dump.cpp | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 35dcd9dbe7..f4f15c1042 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -911,7 +911,7 @@ message GetTimeResponse { option (no_delay) = true; fixed32 epoch_seconds = 1; - string timezone = 2 [deprecated = true]; // Use parsed_timezone instead. Remove before 2026.9.0. + string timezone = 2; ParsedTimezone parsed_timezone = 3; } diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 798deb5197..c880e036cb 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1192,6 +1192,8 @@ void APIConnection::on_get_time_response(const GetTimeResponse &value) { tz.dst_end.week = static_cast(pt.dst_end.week); tz.dst_end.day_of_week = static_cast(pt.dst_end.day_of_week); time::set_global_tz(tz); + } else { + homeassistant::global_homeassistant_time->set_timezone(value.timezone.c_str(), value.timezone.size()); } } #endif diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index e6c4bdba00..c711ef167c 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1147,6 +1147,10 @@ bool ParsedTimezone::decode_length(uint32_t field_id, ProtoLengthDelimited value } bool GetTimeResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { + case 2: { + this->timezone = StringRef(reinterpret_cast(value.data()), value.size()); + break; + } case 3: value.decode_to_message(this->parsed_timezone); break; diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 8d002b6dd9..7e926ee0d4 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -1202,11 +1202,12 @@ class ParsedTimezone final : public ProtoDecodableMessage { class GetTimeResponse final : public ProtoDecodableMessage { public: static constexpr uint8_t MESSAGE_TYPE = 37; - static constexpr uint8_t ESTIMATED_SIZE = 22; + static constexpr uint8_t ESTIMATED_SIZE = 31; #ifdef HAS_PROTO_MESSAGE_DUMP const LogString *message_name() const override { return LOG_STR("get_time_response"); } #endif uint32_t epoch_seconds{0}; + StringRef timezone{}; ParsedTimezone parsed_timezone{}; #ifdef HAS_PROTO_MESSAGE_DUMP const char *dump_to(DumpBuffer &out) const override; diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 2bd47a5ed5..850ad37bc9 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -1403,6 +1403,7 @@ const char *ParsedTimezone::dump_to(DumpBuffer &out) const { const char *GetTimeResponse::dump_to(DumpBuffer &out) const { MessageDumpHelper helper(out, ESPHOME_PSTR("GetTimeResponse")); dump_field(out, ESPHOME_PSTR("epoch_seconds"), this->epoch_seconds); + dump_field(out, ESPHOME_PSTR("timezone"), this->timezone); out.append(2, ' ').append_p(ESPHOME_PSTR("parsed_timezone")).append(": "); this->parsed_timezone.dump_to(out); out.append("\n");