mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-27 17:23:51 +00:00
Some changes for fetching prices from amshub
This commit is contained in:
@@ -190,6 +190,7 @@ struct EntsoeConfig {
|
||||
char area[17];
|
||||
char currency[4];
|
||||
uint32_t multiplier;
|
||||
bool enabled;
|
||||
}; // 62
|
||||
|
||||
struct EnergyAccountingConfig {
|
||||
|
||||
@@ -868,6 +868,11 @@ bool AmsConfiguration::relocateConfig96() {
|
||||
strcpy(ntp.server, ntp96.server);
|
||||
EEPROM.put(CONFIG_NTP_START, ntp);
|
||||
|
||||
EntsoeConfig entsoe;
|
||||
EEPROM.get(CONFIG_ENTSOE_START, entsoe);
|
||||
entsoe.enabled = strlen(entsoe.token) > 0;
|
||||
EEPROM.put(CONFIG_ENTSOE_START, entsoe);
|
||||
|
||||
EEPROM.put(EEPROM_CONFIG_ADDRESS, 100);
|
||||
bool ret = EEPROM.commit();
|
||||
EEPROM.end();
|
||||
|
||||
@@ -131,6 +131,8 @@ bool EntsoeApi::loop() {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if(!config->enabled)
|
||||
return false;
|
||||
if(strlen(config->area) == 0)
|
||||
return false;
|
||||
if(strlen(config->currency) == 0)
|
||||
|
||||
@@ -192,14 +192,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if sysinfo.chip != 'esp8266'}
|
||||
<div class="my-1">
|
||||
<label><input type="checkbox" name="pe" bind:checked={configuration.p.e} class="rounded mb-1"/> ENTSO-E token</label>
|
||||
{#if configuration.p.e}
|
||||
<label><input type="checkbox" name="pe" bind:checked={configuration.p.e} class="rounded mb-1"/> Enable price fetch from remote server</label>
|
||||
{#if configuration.p.e && sysinfo.chip != 'esp8266'}
|
||||
<br/><input name="pt" bind:value={configuration.p.t} type="text" class="in-s"/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="my-1">
|
||||
Security<br/>
|
||||
<select name="gs" bind:value={configuration.g.s} class="in-s">
|
||||
|
||||
@@ -802,7 +802,7 @@ void AmsWebServer::configurationJson() {
|
||||
);
|
||||
server.sendContent(buf);
|
||||
snprintf_P(buf, BufferSize, CONF_PRICE_JSON,
|
||||
strlen(entsoe.token) > 0 ? "true" : "false",
|
||||
entsoe.enabled ? "true" : "false",
|
||||
entsoe.token,
|
||||
entsoe.area,
|
||||
entsoe.currency,
|
||||
@@ -1220,6 +1220,7 @@ void AmsWebServer::handleSave() {
|
||||
if(server.hasArg(F("p")) && server.arg(F("p")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received price API config"));
|
||||
EntsoeConfig entsoe;
|
||||
entsoe.enabled = server.hasArg(F("pe")) && server.arg(F("pe")) == F("true");
|
||||
strcpy(entsoe.token, server.arg(F("pt")).c_str());
|
||||
strcpy(entsoe.area, server.arg(F("pr")).c_str());
|
||||
strcpy(entsoe.currency, server.arg(F("pc")).c_str());
|
||||
|
||||
Reference in New Issue
Block a user