From 0bd4330881136c97a9c7a18a47096ef284b0e596 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 14 Oct 2023 18:31:39 +0200 Subject: [PATCH] shower time --- src/shower.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shower.cpp b/src/shower.cpp index 973198550..1d91b9a42 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -104,6 +104,13 @@ void Shower::loop() { // char s[50]; // snprintf(s, 50, "%02u:%02u:%02u", (uint8_t)(duration_ / 3600000UL), (uint8_t)(duration_ / 60000UL), (uint8_t)((duration_ / 1000UL) % 60)); doc["duration"] = (duration_ / 1000UL); // seconds + time_t now = time(nullptr); + if (now > 1576800000) { // year 2020 + tm * tm_ = localtime(&now); + char dt[20]; + strftime(dt, sizeof(dt), "%T", tm_); + doc["time"] = dt; + } Mqtt::queue_publish("shower_data", doc.as()); LOG_INFO("finished with duration %lu seconds", duration_ / 1000UL); }