Merge pull request #6468 from pablozg/development

NRG: Show usage/export stored values when EnergyReset command is sent
This commit is contained in:
Theo Arends 2019-09-21 14:55:17 +02:00 committed by GitHub
commit 206a502f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View File

@ -175,6 +175,8 @@
#define D_JSON_PV2_CURRENT "Pv2Current"
#define D_JSON_PV2_POWER "Pv2Power"
#define D_JSON_SOLAR_POWER "SolarPower"
#define D_JSON_USAGE "Usage"
#define D_JSON_EXPORT "Export"
#define D_RSLT_ENERGY "ENERGY"
#define D_RSLT_HASS_STATE "HASS_STATE"

View File

@ -504,16 +504,6 @@ void CmndEnergyReset(void)
break;
}
}
char energy_total_chr[FLOATSZ];
dtostrfd(Energy.total, Settings.flag2.energy_resolution, energy_total_chr);
char energy_daily_chr[FLOATSZ];
dtostrfd(Energy.daily, Settings.flag2.energy_resolution, energy_daily_chr);
char energy_yesterday_chr[FLOATSZ];
dtostrfd((float)Settings.energy_kWhyesterday / 100000, Settings.flag2.energy_resolution, energy_yesterday_chr);
Response_P(PSTR("{\"%s\":{\"" D_JSON_TOTAL "\":%s,\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s}}"),
XdrvMailbox.command, energy_total_chr, energy_yesterday_chr, energy_daily_chr);
}
if ((XdrvMailbox.index > 3) && (XdrvMailbox.index <= 5)) {
@ -546,12 +536,18 @@ void CmndEnergyReset(void)
Settings.energy_usage.return2_kWhtotal = RtcSettings.energy_usage.return2_kWhtotal;
break;
}
}
Response_P(PSTR("{\"%s\":{\"Usage\":[%d,%d],\"Export\":[%d,%d]}}"),
XdrvMailbox.command,
char energy_total_chr[FLOATSZ];
dtostrfd(Energy.total, Settings.flag2.energy_resolution, energy_total_chr);
char energy_daily_chr[FLOATSZ];
dtostrfd(Energy.daily, Settings.flag2.energy_resolution, energy_daily_chr);
char energy_yesterday_chr[FLOATSZ];
dtostrfd((float)Settings.energy_kWhyesterday / 100000, Settings.flag2.energy_resolution, energy_yesterday_chr);
Response_P(PSTR("{\"%s\":{\"" D_JSON_TOTAL "\":%s,\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s,\"" D_JSON_USAGE "\":[%d,%d],\"" D_JSON_EXPORT "\":[%d,%d]}}"),
XdrvMailbox.command, energy_total_chr, energy_yesterday_chr, energy_daily_chr,
Settings.energy_usage.usage1_kWhtotal, Settings.energy_usage.usage2_kWhtotal,
Settings.energy_usage.return1_kWhtotal, Settings.energy_usage.return2_kWhtotal);
}
}
void CmndTariff(void)