diff --git a/src/mqtt/HomeAssistantMqttHandler.cpp b/src/mqtt/HomeAssistantMqttHandler.cpp index 18057c2b..969db87c 100644 --- a/src/mqtt/HomeAssistantMqttHandler.cpp +++ b/src/mqtt/HomeAssistantMqttHandler.cpp @@ -6,6 +6,7 @@ #include "web/root/ha1_json.h" #include "web/root/ha2_json.h" #include "web/root/ha3_json.h" +#include "web/root/ha4_json.h" #include "web/root/jsonsys_json.h" #include "web/root/jsonprices_json.h" #include "web/root/hadiscover_json.h" @@ -34,8 +35,25 @@ bool HomeAssistantMqttHandler::publish(AmsData* data, AmsData* previousState, En data->getActiveImportPower() ); mqtt->publish(topic + "/power", json); - } else if(data->getListType() >= 2) { // publish power counts and volts/amps + } else if(data->getListType() <= 3) { // publish power counts and volts/amps snprintf_P(json, BufferSize, HA3_JSON, + data->getListId().c_str(), + data->getMeterId().c_str(), + meterModel.c_str(), + data->getActiveImportPower(), + data->getReactiveImportPower(), + data->getActiveExportPower(), + data->getReactiveExportPower(), + data->getL1Current(), + data->getL2Current(), + data->getL3Current(), + data->getL1Voltage(), + data->getL2Voltage(), + data->getL3Voltage() + ); + mqtt->publish(topic + "/power", json); + } else if(data->getListType() == 4) { // publish power counts and volts/amps/phase power and PF + snprintf_P(json, BufferSize, HA4_JSON, data->getListId().c_str(), data->getMeterId().c_str(), meterModel.c_str(), diff --git a/web/ha3.json b/web/ha3.json index faee4724..8fa16c93 100644 --- a/web/ha3.json +++ b/web/ha3.json @@ -3,23 +3,13 @@ "id" : "%s", "type" : "%s", "P" : %d, - "P1" : %.2f, - "P2" : %.2f, - "P3" : %.2f, "Q" : %d, "PO" : %d, - "PO1" : %.2f, - "PO2" : %.2f, - "PO3" : %.2f, "QO" : %d, "I1" : %.2f, "I2" : %.2f, "I3" : %.2f, "U1" : %.2f, "U2" : %.2f, - "U3" : %.2f, - "PF" : %.2f, - "PF1" : %.2f, - "PF2" : %.2f, - "PF3" : %.2f + "U3" : %.2f } diff --git a/web/ha4.json b/web/ha4.json new file mode 100644 index 00000000..faee4724 --- /dev/null +++ b/web/ha4.json @@ -0,0 +1,25 @@ +{ + "lv" : "%s", + "id" : "%s", + "type" : "%s", + "P" : %d, + "P1" : %.2f, + "P2" : %.2f, + "P3" : %.2f, + "Q" : %d, + "PO" : %d, + "PO1" : %.2f, + "PO2" : %.2f, + "PO3" : %.2f, + "QO" : %d, + "I1" : %.2f, + "I2" : %.2f, + "I3" : %.2f, + "U1" : %.2f, + "U2" : %.2f, + "U3" : %.2f, + "PF" : %.2f, + "PF1" : %.2f, + "PF2" : %.2f, + "PF3" : %.2f +}