From 8be7beab9a471df27e468a43b7567c19be3a4832 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Wed, 30 Nov 2022 20:25:03 +0100 Subject: [PATCH] Add the timezone to the time output fomat (#1435) * Add the timezone to the time output fomat, see https://github.com/jomjol/AI-on-the-edge-device/issues/1428 * use correct device class for timestamp --- .../jomjol_flowcontroll/ClassFlowPostProcessing.cpp | 2 +- code/components/jomjol_mqtt/server_mqtt.cpp | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index 2691118b..037703a1 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -17,7 +17,7 @@ static const char* TAG = "FLOW POSTPROC"; //#define SERIAL_DEBUG // testing debug on serial enabled -#define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S" +#define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S%z" #define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d" diff --git a/code/components/jomjol_mqtt/server_mqtt.cpp b/code/components/jomjol_mqtt/server_mqtt.cpp index 53cf0537..bb074b3d 100644 --- a/code/components/jomjol_mqtt/server_mqtt.cpp +++ b/code/components/jomjol_mqtt/server_mqtt.cpp @@ -150,11 +150,7 @@ void MQTThomeassistantDiscovery() { // sendHomeAssistantDiscoveryTopic(group, "rate", "Rate (Unit/Minute)", "swap-vertical", "", "", "", ""); // Legacy, always Unit per Minute sendHomeAssistantDiscoveryTopic(group, "rate_per_time_unit", "Rate (" + rateUnit + ")", "swap-vertical", rateUnit, "", "", ""); sendHomeAssistantDiscoveryTopic(group, "rate_per_digitalization_round", "Change since last digitalization round", "arrow-expand-vertical", valueUnit, "", "measurement", ""); // correctly the Unit is Uint/Interval! - /* The timestamp string misses the Timezone, see PREVALUE_TIME_FORMAT_OUTPUT! - We need to know the timezone and append it! Until we do this, we simply - do not set the device class to "timestamp" to avoid errors in Homeassistant! */ - // sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "timestamp", "", "diagnostic"); - sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "", "", "diagnostic"); + sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "timestamp", "", "diagnostic"); sendHomeAssistantDiscoveryTopic(group, "json", "JSON", "code-json", "", "", "", "diagnostic"); sendHomeAssistantDiscoveryTopic(group, "problem", "Problem", "alert-outline", "", "", "", ""); // Special binary sensor which is based on error topic }