mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-05-01 05:59:24 +00:00
Added power factor to MQTT JSON
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "web/root/json1_json.h"
|
#include "web/root/json1_json.h"
|
||||||
#include "web/root/json2_json.h"
|
#include "web/root/json2_json.h"
|
||||||
#include "web/root/json3_json.h"
|
#include "web/root/json3_json.h"
|
||||||
|
#include "web/root/json3pf_json.h"
|
||||||
#include "web/root/jsonsys_json.h"
|
#include "web/root/jsonsys_json.h"
|
||||||
#include "web/root/jsonprices_json.h"
|
#include "web/root/jsonprices_json.h"
|
||||||
|
|
||||||
@@ -50,35 +51,71 @@ bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState) {
|
|||||||
);
|
);
|
||||||
return mqtt->publish(topic, json);
|
return mqtt->publish(topic, json);
|
||||||
} else if(data->getListType() == 3) {
|
} else if(data->getListType() == 3) {
|
||||||
char json[512];
|
if(data->getPowerFactor() == 0) {
|
||||||
snprintf_P(json, sizeof(json), JSON3_JSON,
|
char json[512];
|
||||||
WiFi.macAddress().c_str(),
|
snprintf_P(json, sizeof(json), JSON3_JSON,
|
||||||
clientId.c_str(),
|
WiFi.macAddress().c_str(),
|
||||||
(uint32_t) (millis64()/1000),
|
clientId.c_str(),
|
||||||
data->getPackageTimestamp(),
|
(uint32_t) (millis64()/1000),
|
||||||
hw->getVcc(),
|
data->getPackageTimestamp(),
|
||||||
hw->getWifiRssi(),
|
hw->getVcc(),
|
||||||
hw->getTemperature(),
|
hw->getWifiRssi(),
|
||||||
data->getListId().c_str(),
|
hw->getTemperature(),
|
||||||
data->getMeterId().c_str(),
|
data->getListId().c_str(),
|
||||||
data->getMeterModel().c_str(),
|
data->getMeterId().c_str(),
|
||||||
data->getActiveImportPower(),
|
data->getMeterModel().c_str(),
|
||||||
data->getReactiveImportPower(),
|
data->getActiveImportPower(),
|
||||||
data->getActiveExportPower(),
|
data->getReactiveImportPower(),
|
||||||
data->getReactiveExportPower(),
|
data->getActiveExportPower(),
|
||||||
data->getL1Current(),
|
data->getReactiveExportPower(),
|
||||||
data->getL2Current(),
|
data->getL1Current(),
|
||||||
data->getL3Current(),
|
data->getL2Current(),
|
||||||
data->getL1Voltage(),
|
data->getL3Current(),
|
||||||
data->getL2Voltage(),
|
data->getL1Voltage(),
|
||||||
data->getL3Voltage(),
|
data->getL2Voltage(),
|
||||||
data->getActiveImportCounter(),
|
data->getL3Voltage(),
|
||||||
data->getActiveExportCounter(),
|
data->getActiveImportCounter(),
|
||||||
data->getReactiveImportCounter(),
|
data->getActiveExportCounter(),
|
||||||
data->getReactiveExportCounter(),
|
data->getReactiveImportCounter(),
|
||||||
data->getMeterTimestamp()
|
data->getReactiveExportCounter(),
|
||||||
);
|
data->getMeterTimestamp()
|
||||||
return mqtt->publish(topic, json);
|
);
|
||||||
|
return mqtt->publish(topic, json);
|
||||||
|
} else {
|
||||||
|
char json[768];
|
||||||
|
snprintf_P(json, sizeof(json), JSON3PF_JSON,
|
||||||
|
WiFi.macAddress().c_str(),
|
||||||
|
clientId.c_str(),
|
||||||
|
(uint32_t) (millis64()/1000),
|
||||||
|
data->getPackageTimestamp(),
|
||||||
|
hw->getVcc(),
|
||||||
|
hw->getWifiRssi(),
|
||||||
|
hw->getTemperature(),
|
||||||
|
data->getListId().c_str(),
|
||||||
|
data->getMeterId().c_str(),
|
||||||
|
data->getMeterModel().c_str(),
|
||||||
|
data->getActiveImportPower(),
|
||||||
|
data->getReactiveImportPower(),
|
||||||
|
data->getActiveExportPower(),
|
||||||
|
data->getReactiveExportPower(),
|
||||||
|
data->getL1Current(),
|
||||||
|
data->getL2Current(),
|
||||||
|
data->getL3Current(),
|
||||||
|
data->getL1Voltage(),
|
||||||
|
data->getL2Voltage(),
|
||||||
|
data->getL3Voltage(),
|
||||||
|
data->getPowerFactor(),
|
||||||
|
data->getL1PowerFactor(),
|
||||||
|
data->getL2PowerFactor(),
|
||||||
|
data->getL3PowerFactor(),
|
||||||
|
data->getActiveImportCounter(),
|
||||||
|
data->getActiveExportCounter(),
|
||||||
|
data->getReactiveImportCounter(),
|
||||||
|
data->getReactiveExportCounter(),
|
||||||
|
data->getMeterTimestamp()
|
||||||
|
);
|
||||||
|
return mqtt->publish(topic, json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
33
web/json3pf.json
Normal file
33
web/json3pf.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"id" : "%s",
|
||||||
|
"name" : "%s",
|
||||||
|
"up" : %lu,
|
||||||
|
"t" : %lu,
|
||||||
|
"vcc" : %.3f,
|
||||||
|
"rssi": %d,
|
||||||
|
"temp": %.2f,
|
||||||
|
"data" : {
|
||||||
|
"lv" : "%s",
|
||||||
|
"id" : "%s",
|
||||||
|
"type" : "%s",
|
||||||
|
"P" : %d,
|
||||||
|
"Q" : %d,
|
||||||
|
"PO" : %d,
|
||||||
|
"QO" : %d,
|
||||||
|
"I1" : %.2f,
|
||||||
|
"I2" : %.2f,
|
||||||
|
"I3" : %.2f,
|
||||||
|
"U1" : %.2f,
|
||||||
|
"U2" : %.2f,
|
||||||
|
"U3" : %.2f,
|
||||||
|
"PF" : %.2f,
|
||||||
|
"PF1" : %.2f,
|
||||||
|
"PF2" : %.2f,
|
||||||
|
"PF3" : %.2f,
|
||||||
|
"tPI" : %.2f,
|
||||||
|
"tPO" : %.2f,
|
||||||
|
"tQI" : %.2f,
|
||||||
|
"tQO" : %.2f,
|
||||||
|
"rtc" : %lu
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user