mirror of
https://github.com/arendst/Tasmota.git
synced 2026-07-27 20:05:46 +00:00
add PowerTotal and ExportActiveTotal to JSON for multi-phase devices (#24790)
* add PowerTotal and ExportActiveTotal to JSON for multi-phase devices * don't add the fields if SO129=1
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
#define D_JSON_EVERY "Every"
|
||||
#define D_JSON_EXPORT "Export"
|
||||
#define D_JSON_EXPORT_ACTIVE "ExportActive"
|
||||
#define D_JSON_EXPORT_ACTIVE_TOTAL "ExportActiveTotal"
|
||||
#define D_JSON_EXPORT_REACTIVE "ExportReactive"
|
||||
#define D_JSON_EXPORT_POWER "ExportPower"
|
||||
#define D_JSON_FAILED "Failed"
|
||||
@@ -147,6 +148,7 @@
|
||||
#define D_JSON_POWERFACTOR "Factor"
|
||||
#define D_JSON_POWERMAX "MaxPower"
|
||||
#define D_JSON_POWERUSAGE "Power"
|
||||
#define D_JSON_POWERUSAGE_TOTAL "PowerTotal"
|
||||
#define D_JSON_ACTIVE_POWERUSAGE "ActivePower"
|
||||
#define D_JSON_APPARENT_POWERUSAGE "ApparentPower"
|
||||
#define D_JSON_REACTIVE_POWERUSAGE "ReactivePower"
|
||||
|
||||
@@ -721,6 +721,10 @@ void ResponseCmndEnergyTotalYesterdayToday(void) {
|
||||
if (Energy->local_energy_active_export) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution));
|
||||
if (Energy->phase_count > 1 && !Settings->flag5.energy_phase) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE_TOTAL "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, 2));
|
||||
}
|
||||
}
|
||||
ResponseJsonEndEnd();
|
||||
EnergyFmtFree();
|
||||
@@ -1363,7 +1367,11 @@ void EnergyShow(bool json) {
|
||||
EnergyFmt(&Energy->daily_sum_export_balanced, Settings->flag2.energy_resolution, 1));
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, single));
|
||||
|
||||
if (Energy->phase_count > 1 && !Settings->flag5.energy_phase) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE_TOTAL "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, 2));
|
||||
}
|
||||
|
||||
if (energy_tariff) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT D_CMND_TARIFF "\":%s"),
|
||||
EnergyFmt(energy_return, Settings->flag2.energy_resolution, 6));
|
||||
@@ -1382,6 +1390,10 @@ void EnergyShow(bool json) {
|
||||
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_POWERUSAGE "\":%s"),
|
||||
EnergyFmt(Energy->active_power, Settings->flag2.wattage_resolution));
|
||||
if (Energy->phase_count > 1 && !Settings->flag5.energy_phase) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_POWERUSAGE_TOTAL "\":%s"),
|
||||
EnergyFmt(Energy->active_power, Settings->flag2.wattage_resolution, 2));
|
||||
}
|
||||
if (!Energy->type_dc) {
|
||||
if (Energy->current_available && Energy->voltage_available) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_APPARENT_POWERUSAGE "\":%s"),
|
||||
|
||||
@@ -1017,7 +1017,11 @@ void ResponseCmndEnergyTotalYesterdayToday(void) {
|
||||
if (Energy->local_energy_active_export) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution));
|
||||
}
|
||||
if (Energy->phase_count > 1 && !Settings->flag5.energy_phase) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE_TOTAL "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, 2));
|
||||
}
|
||||
}
|
||||
ResponseJsonEndEnd();
|
||||
EnergyFmtFree();
|
||||
}
|
||||
@@ -1707,6 +1711,10 @@ void EnergyShow(bool json) {
|
||||
EnergyFmt(&Energy->daily_sum_export_balanced, Settings->flag2.energy_resolution, 1));
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, single));
|
||||
if (Energy->phase_count > 1 && !Settings->flag5.energy_phase) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE_TOTAL "\":%s"),
|
||||
EnergyFmt(Energy->export_active, Settings->flag2.energy_resolution, 2));
|
||||
}
|
||||
if (energy_tariff) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT D_CMND_TARIFF "\":%s"),
|
||||
EnergyFmt(energy_return_kWh, Settings->flag2.energy_resolution, 6));
|
||||
@@ -1725,6 +1733,10 @@ void EnergyShow(bool json) {
|
||||
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_POWERUSAGE "\":%s"),
|
||||
EnergyFmt(Energy->active_power, Settings->flag2.wattage_resolution));
|
||||
if (Energy->phase_count > 1 && !Settings->flag5.energy_phase) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_POWERUSAGE_TOTAL "\":%s"),
|
||||
EnergyFmt(Energy->active_power, Settings->flag2.wattage_resolution, 2));
|
||||
}
|
||||
if (!Energy->type_dc) {
|
||||
if (Energy->current_available && Energy->voltage_available) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_APPARENT_POWERUSAGE "\":%s"),
|
||||
|
||||
Reference in New Issue
Block a user