Changes for Energy Speedometer connection

This commit is contained in:
Gunnar Skjold
2023-10-20 13:26:38 +02:00
parent f7cb022e3e
commit 1ceffd0bc9
16 changed files with 190 additions and 43 deletions

View File

@@ -30,6 +30,7 @@
#include "html/conf_domoticz_json.h"
#include "html/conf_ha_json.h"
#include "html/conf_ui_json.h"
#include "html/conf_cloud_json.h"
#include "html/firmware_html.h"
#if defined(ESP32)
@@ -788,6 +789,8 @@ void AmsWebServer::configurationJson() {
if(!checkSecurity(1))
return;
SystemConfig sysConfig;
config->getSystemConfig(sysConfig);
NtpConfig ntpConfig;
config->getNtpConfig(ntpConfig);
WiFiConfig wifiConfig;
@@ -973,6 +976,14 @@ void AmsWebServer::configurationJson() {
haconf.discoveryNameTag
);
server.sendContent(buf);
snprintf_P(buf, BufferSize, CONF_CLOUD_JSON,
#if defined(ENERGY_SPEEDOMETER_PASS)
sysConfig.energyspeedometer ? "true" : "false"
#else
"null"
#endif
);
server.sendContent(buf);
server.sendContent_P(PSTR("}"));
}
@@ -1468,6 +1479,14 @@ void AmsWebServer::handleSave() {
config->setEnergyAccountingConfig(eac);
}
if(server.hasArg(F("c")) && server.arg(F("c")) == F("true")) {
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received cloud config\n"));
SystemConfig sys;
config->getSystemConfig(sys);
sys.energyspeedometer = server.hasArg(F("ces")) && server.arg(F("ces")) == F("true");
config->setSystemConfig(sys);
}
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Saving configuration now...\n"));
if (config->save()) {