implemented "patrix/json"

This commit is contained in:
Patrick Haßel 2024-12-19 10:12:01 +01:00
parent 0cc55f3b87
commit 1836cfbe8a
2 changed files with 9 additions and 1 deletions

View File

@ -63,7 +63,7 @@ def do_main():
if 1: if 1:
# Add the description of the current git revision # 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")) updateFileIfChanged(targetfile, bytes(lines, "utf-8"))

View File

@ -32,6 +32,14 @@ void MqttHandleInverterTotalClass::loop()
return; 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/power", String(Datastore.getTotalAcPowerEnabled(), Datastore.getTotalAcPowerDigits()));
MqttSettings.publish("ac/yieldtotal", String(Datastore.getTotalAcYieldTotalEnabled(), Datastore.getTotalAcYieldTotalDigits())); MqttSettings.publish("ac/yieldtotal", String(Datastore.getTotalAcYieldTotalEnabled(), Datastore.getTotalAcYieldTotalDigits()));
MqttSettings.publish("ac/yieldday", String(Datastore.getTotalAcYieldDayEnabled(), Datastore.getTotalAcYieldDayDigits())); MqttSettings.publish("ac/yieldday", String(Datastore.getTotalAcYieldDayEnabled(), Datastore.getTotalAcYieldDayDigits()));