From 1836cfbe8ac0591c2df40fe61ae45a457b753b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Thu, 19 Dec 2024 10:12:01 +0100 Subject: [PATCH] implemented "patrix/json" --- pio-scripts/auto_firmware_version.py | 2 +- src/MqttHandleInverterTotal.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pio-scripts/auto_firmware_version.py b/pio-scripts/auto_firmware_version.py index 26e1bd65..00e63d24 100644 --- a/pio-scripts/auto_firmware_version.py +++ b/pio-scripts/auto_firmware_version.py @@ -63,7 +63,7 @@ def do_main(): if 1: # Add the description of the current git revision - lines += 'const char *__COMPILED_GIT_HASH__ = "%s";\n' % (get_build_version()) + lines += 'const char *__COMPILED_GIT_HASH__ = "%s-patrix";\n' % (get_build_version()) updateFileIfChanged(targetfile, bytes(lines, "utf-8")) diff --git a/src/MqttHandleInverterTotal.cpp b/src/MqttHandleInverterTotal.cpp index 5f5be6a9..706e2d11 100644 --- a/src/MqttHandleInverterTotal.cpp +++ b/src/MqttHandleInverterTotal.cpp @@ -32,6 +32,14 @@ void MqttHandleInverterTotalClass::loop() return; } + float power = Datastore.getTotalAcPowerEnabled(); + float energy = Datastore.getTotalAcYieldTotalEnabled(); + if (!isnan(power) && !isnan(energy)) { + char buffer[200]; + snprintf(buffer, sizeof buffer, R"({"timestamp": %ld, "energyProducedKWh": %f, "powerW": %f})", std::time(nullptr), energy, power); + MqttSettings.publish("patrix/json", buffer); + } + MqttSettings.publish("ac/power", String(Datastore.getTotalAcPowerEnabled(), Datastore.getTotalAcPowerDigits())); MqttSettings.publish("ac/yieldtotal", String(Datastore.getTotalAcYieldTotalEnabled(), Datastore.getTotalAcYieldTotalDigits())); MqttSettings.publish("ac/yieldday", String(Datastore.getTotalAcYieldDayEnabled(), Datastore.getTotalAcYieldDayDigits()));