From d7229686a9e9818f0d59af2659063adff5de99be Mon Sep 17 00:00:00 2001 From: agessaman Date: Mon, 20 Jul 2026 15:36:22 -0700 Subject: [PATCH] refactor(mqtt): reorder timezone command handling for clarity Adjust the command handling in CommonCLI_Observer to prioritize the more specific "timezone.offset" check before the general "timezone" check. This change prevents incorrect responses when querying the timezone offset, improving the clarity and correctness of command responses. --- src/helpers/CommonCLI_Observer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/CommonCLI_Observer.cpp b/src/helpers/CommonCLI_Observer.cpp index 9563930b..0a342921 100644 --- a/src/helpers/CommonCLI_Observer.cpp +++ b/src/helpers/CommonCLI_Observer.cpp @@ -911,10 +911,13 @@ bool CommonCLI::handleObserverGetCmd(uint32_t sender_timestamp, const char* conf uint8_t ps = _mqtt_prefs.wifi_power_save; const char* ps_name = (ps == 1) ? "none" : (ps == 2) ? "max" : "min"; sprintf(reply, "> %s", ps_name); + } else if (memcmp(config, "timezone.offset", 15) == 0) { + // Must precede the "timezone" (8-byte) check below — that prefix-matches + // "timezone.offset" too, so the more-specific key has to come first or + // `get timezone.offset` returns the string and never the offset (A3). + sprintf(reply, "> %d", _mqtt_prefs.timezone_offset); } else if (memcmp(config, "timezone", 8) == 0) { sprintf(reply, "> %s", _mqtt_prefs.timezone_string); - } else if (memcmp(config, "timezone.offset", 15) == 0) { - sprintf(reply, "> %d", _mqtt_prefs.timezone_offset); } else if (memcmp(config, "mqtt.analyzer.us", 17) == 0) { sprintf(reply, "> %s", strcmp(_mqtt_prefs.mqtt_slot_preset[0], "analyzer-us") == 0 ? "on" : "off"); } else if (memcmp(config, "mqtt.analyzer.eu", 17) == 0) {