From 24ceb3e97ecba54b2a0e9af8c95e301bd5762230 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 5 Aug 2024 01:05:16 +0200 Subject: [PATCH] 0.8.130 * add timestamp to JSON output #1707 * restart Ahoy using MqTT #1667 --- src/CHANGES.md | 2 ++ src/publisher/pubMqtt.h | 7 +++++-- src/publisher/pubMqttIvData.h | 1 + src/web/RestApi.h | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index be7ee81c..133e145a 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -5,6 +5,8 @@ * merge PR: Power limit command accelerated #1704 * merge PR: reduce update cycle of ePaper from 5 to 10 seconds #1706 * merge PR: small fixes in different files #1711 +* add timestamp to JSON output #1707 +* restart Ahoy using MqTT #1667 ## 0.8.129 - 2024-07-11 * sort alarms ascending #1471 diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 28cfb358..6e021bed 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -285,6 +285,9 @@ class PubMqtt { tickerMinute(); publish(mLwtTopic.data(), mqttStr[MQTT_STR_LWT_CONN], true, false); + snprintf(mVal.data(), mVal.size(), "ctrl/restart_ahoy"); + subscribe(mVal.data()); + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { snprintf(mVal.data(), mVal.size(), "ctrl/limit/%d", i); subscribe(mVal.data(), QOS_2); @@ -386,9 +389,9 @@ class PubMqtt { pos++; } - /*char out[128]; + char out[128]; serializeJson(root, out, 128); - DPRINTLN(DBG_INFO, "json: " + String(out));*/ + DPRINTLN(DBG_INFO, "json: " + String(out)); (mSubscriptionCb)(root); mRxCnt++; diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 7965cde6..5ba21f6d 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -231,6 +231,7 @@ class PubMqttIvData { publish = true; if (publish) { + doc[F("ts")] = rec->ts; // if next channel or end->publish serializeJson(doc, mVal.data(), mVal.size()); snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d", mIv->config->name, rec->assign[mPos].ch); diff --git a/src/web/RestApi.h b/src/web/RestApi.h index fd4bbaae..9d2d9644 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -1072,6 +1072,8 @@ class RestApi { } else if(F("dev") == jsonIn[F("cmd")]) { DPRINTLN(DBG_INFO, F("dev cmd")); iv->setDevCommand(jsonIn[F("val")].as()); + } else if(F("restart_ahoy") == jsonIn[F("cmd")]) { + mApp->setRebootFlag(); } else { jsonOut[F("error")] = F("ERR_UNKNOWN_CMD"); return false;