diff --git a/lib/AmsConfiguration/include/AmsConfiguration.h b/lib/AmsConfiguration/include/AmsConfiguration.h index bca51ed4..bfa2438d 100644 --- a/lib/AmsConfiguration/include/AmsConfiguration.h +++ b/lib/AmsConfiguration/include/AmsConfiguration.h @@ -20,7 +20,7 @@ #define CONFIG_NETWORK_START 40 #define CONFIG_METER_START 296 #define CONFIG_GPIO_START 368 -#define CONFIG_ENTSOE_START 400 +#define CONFIG_PRICE_START 400 #define CONFIG_ENERGYACCOUNTING_START 464 #define CONFIG_WEB_START 488 #define CONFIG_DEBUG_START 624 @@ -184,8 +184,8 @@ struct NtpConfig { char timezone[32]; }; // 98 -struct EntsoeConfig { - char token[37]; +struct PriceServiceConfig { + char entsoeToken[37]; char area[17]; char currency[4]; uint32_t multiplier; @@ -304,11 +304,11 @@ public: bool isNtpChanged(); void ackNtpChange(); - bool getEntsoeConfig(EntsoeConfig&); - bool setEntsoeConfig(EntsoeConfig&); - void clearEntsoe(EntsoeConfig&); - bool isEntsoeChanged(); - void ackEntsoeChange(); + bool getPriceServiceConfig(PriceServiceConfig&); + bool setPriceServiceConfig(PriceServiceConfig&); + void clearPriceServiceConfig(PriceServiceConfig&); + bool isPriceServiceChanged(); + void ackPriceServiceChange(); bool getEnergyAccountingConfig(EnergyAccountingConfig&); bool setEnergyAccountingConfig(EnergyAccountingConfig&); @@ -337,7 +337,7 @@ protected: private: uint8_t configVersion = 0; - bool sysChanged = false, networkChanged, mqttChanged, meterChanged = true, ntpChanged = true, entsoeChanged = false, energyAccountingChanged = true, cloudChanged = true; + bool sysChanged = false, networkChanged, mqttChanged, meterChanged = true, ntpChanged = true, priceChanged = false, energyAccountingChanged = true, cloudChanged = true; bool relocateConfig101(); // 2.2.0 through 2.2.8 bool relocateConfig102(); // 2.2.9 through 2.2.11 diff --git a/lib/AmsConfiguration/src/AmsConfiguration.cpp b/lib/AmsConfiguration/src/AmsConfiguration.cpp index 858a95fb..2b4dc540 100644 --- a/lib/AmsConfiguration/src/AmsConfiguration.cpp +++ b/lib/AmsConfiguration/src/AmsConfiguration.cpp @@ -570,47 +570,47 @@ void AmsConfiguration::clearNtp(NtpConfig& config) { strcpy(config.timezone, "Europe/Oslo"); } -bool AmsConfiguration::getEntsoeConfig(EntsoeConfig& config) { +bool AmsConfiguration::getPriceServiceConfig(PriceServiceConfig& config) { if(hasConfig()) { EEPROM.begin(EEPROM_SIZE); - EEPROM.get(CONFIG_ENTSOE_START, config); + EEPROM.get(CONFIG_PRICE_START, config); EEPROM.end(); - if(strlen(config.token) != 0 && strlen(config.token) != 36) { - clearEntsoe(config); + if(strlen(config.entsoeToken) != 0 && strlen(config.entsoeToken) != 36) { + clearPriceServiceConfig(config); } return true; } else { - clearEntsoe(config); + clearPriceServiceConfig(config); return false; } } -bool AmsConfiguration::setEntsoeConfig(EntsoeConfig& config) { - EntsoeConfig existing; - if(getEntsoeConfig(existing)) { - entsoeChanged |= strcmp(config.token, existing.token) != 0; - entsoeChanged |= strcmp(config.area, existing.area) != 0; - entsoeChanged |= strcmp(config.currency, existing.currency) != 0; - entsoeChanged |= config.multiplier != existing.multiplier; - entsoeChanged |= config.enabled != existing.enabled; - entsoeChanged |= config.fixedPrice != existing.fixedPrice; +bool AmsConfiguration::setPriceServiceConfig(PriceServiceConfig& config) { + PriceServiceConfig existing; + if(getPriceServiceConfig(existing)) { + priceChanged |= strcmp(config.entsoeToken, existing.entsoeToken) != 0; + priceChanged |= strcmp(config.area, existing.area) != 0; + priceChanged |= strcmp(config.currency, existing.currency) != 0; + priceChanged |= config.multiplier != existing.multiplier; + priceChanged |= config.enabled != existing.enabled; + priceChanged |= config.fixedPrice != existing.fixedPrice; } else { - entsoeChanged = true; + priceChanged = true; } - stripNonAscii((uint8_t*) config.token, 37); + stripNonAscii((uint8_t*) config.entsoeToken, 37); stripNonAscii((uint8_t*) config.area, 17); stripNonAscii((uint8_t*) config.currency, 4); EEPROM.begin(EEPROM_SIZE); - EEPROM.put(CONFIG_ENTSOE_START, config); + EEPROM.put(CONFIG_PRICE_START, config); bool ret = EEPROM.commit(); EEPROM.end(); return ret; } -void AmsConfiguration::clearEntsoe(EntsoeConfig& config) { - strcpy(config.token, ""); +void AmsConfiguration::clearPriceServiceConfig(PriceServiceConfig& config) { + strcpy(config.entsoeToken, ""); strcpy(config.area, ""); strcpy(config.currency, ""); config.multiplier = 1000; @@ -618,12 +618,12 @@ void AmsConfiguration::clearEntsoe(EntsoeConfig& config) { config.fixedPrice = 0; } -bool AmsConfiguration::isEntsoeChanged() { - return entsoeChanged; +bool AmsConfiguration::isPriceServiceChanged() { + return priceChanged; } -void AmsConfiguration::ackEntsoeChange() { - entsoeChanged = false; +void AmsConfiguration::ackPriceServiceChange() { + priceChanged = false; } @@ -856,9 +856,9 @@ void AmsConfiguration::clear() { clearNtp(ntp); EEPROM.put(CONFIG_NTP_START, ntp); - EntsoeConfig entsoe; - clearEntsoe(entsoe); - EEPROM.put(CONFIG_ENTSOE_START, entsoe); + PriceServiceConfig price; + clearPriceServiceConfig(price); + EEPROM.put(CONFIG_PRICE_START, price); EnergyAccountingConfig eac; clearEnergyAccountingConfig(eac); @@ -968,7 +968,7 @@ bool AmsConfiguration::relocateConfig102() { clearHomeAssistantConfig(haconf); EEPROM.put(CONFIG_HA_START_103, haconf); - EntsoeConfig entsoe; + PriceServiceConfig entsoe; EEPROM.get(CONFIG_ENTSOE_START_103, entsoe); entsoe.fixedPrice = 0; EEPROM.put(CONFIG_ENTSOE_START_103, entsoe); @@ -986,7 +986,7 @@ bool AmsConfiguration::relocateConfig103() { UpgradeInformation upinfo; UiConfig ui; GpioConfig103 gpio103; - EntsoeConfig entsoe; + PriceServiceConfig price; NetworkConfig wifi; EnergyAccountingConfig eac; WebConfig web; @@ -1000,7 +1000,7 @@ bool AmsConfiguration::relocateConfig103() { EEPROM.get(CONFIG_UPGRADE_INFO_START_103, upinfo); EEPROM.get(CONFIG_UI_START_103, ui); EEPROM.get(CONFIG_GPIO_START_103, gpio103); - EEPROM.get(CONFIG_ENTSOE_START_103, entsoe); + EEPROM.get(CONFIG_ENTSOE_START_103, price); EEPROM.get(CONFIG_WIFI_START_103, wifi); EEPROM.get(CONFIG_ENERGYACCOUNTING_START_103, eac); EEPROM.get(CONFIG_WEB_START_103, web); @@ -1039,7 +1039,7 @@ bool AmsConfiguration::relocateConfig103() { EEPROM.put(CONFIG_NETWORK_START, wifi); EEPROM.put(CONFIG_METER_START, meter); EEPROM.put(CONFIG_GPIO_START, gpio); - EEPROM.put(CONFIG_ENTSOE_START, entsoe); + EEPROM.put(CONFIG_PRICE_START, price); EEPROM.put(CONFIG_ENERGYACCOUNTING_START, eac); EEPROM.put(CONFIG_WEB_START, web); EEPROM.put(CONFIG_DEBUG_START, debug); @@ -1232,14 +1232,14 @@ void AmsConfiguration::print(Print* debugger) debugger->flush(); } - EntsoeConfig entsoe; - if(getEntsoeConfig(entsoe)) { - if(strlen(entsoe.area) > 0) { - debugger->println(F("--ENTSO-E configuration--")); - debugger->printf_P(PSTR("Area: %s\r\n"), entsoe.area); - debugger->printf_P(PSTR("Currency: %s\r\n"), entsoe.currency); - debugger->printf_P(PSTR("Multiplier: %f\r\n"), entsoe.multiplier / 1000.0); - debugger->printf_P(PSTR("Token: %s\r\n"), entsoe.token); + PriceServiceConfig price; + if(getPriceServiceConfig(price)) { + if(strlen(price.area) > 0) { + debugger->println(F("--Price configuration--")); + debugger->printf_P(PSTR("Area: %s\r\n"), price.area); + debugger->printf_P(PSTR("Currency: %s\r\n"), price.currency); + debugger->printf_P(PSTR("Multiplier: %f\r\n"), price.multiplier / 1000.0); + debugger->printf_P(PSTR("ENTSO-E Token: %s\r\n"), price.entsoeToken); } debugger->println(F("")); delay(10); diff --git a/lib/AmsMqttHandler/include/AmsMqttHandler.h b/lib/AmsMqttHandler/include/AmsMqttHandler.h index c3f2cb3b..cc80f4ca 100644 --- a/lib/AmsMqttHandler/include/AmsMqttHandler.h +++ b/lib/AmsMqttHandler/include/AmsMqttHandler.h @@ -13,7 +13,7 @@ #include "AmsConfiguration.h" #include "EnergyAccounting.h" #include "HwTools.h" -#include "EntsoeApi.h" +#include "PriceService.h" #if defined(ESP32) #include @@ -38,10 +38,10 @@ public: virtual uint8_t getFormat() { return 0; }; - virtual bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { return false; }; + virtual bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) { return false; }; virtual bool publishTemperatures(AmsConfiguration*, HwTools*) { return false; }; - virtual bool publishPrices(EntsoeApi* eapi) { return false; }; - virtual bool publishSystem(HwTools*, EntsoeApi*, EnergyAccounting*) { return false; }; + virtual bool publishPrices(PriceService* ps) { return false; }; + virtual bool publishSystem(HwTools*, PriceService*, EnergyAccounting*) { return false; }; virtual bool publishRaw(String data) { return false; }; virtual ~AmsMqttHandler() { diff --git a/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h b/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h index 3b51f57a..21e549ea 100644 --- a/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h +++ b/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h @@ -15,10 +15,10 @@ public: DomoticzMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf, DomoticzConfig config) : AmsMqttHandler(mqttConfig, debugger, buf) { this->config = config; }; - bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); + bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps); bool publishTemperatures(AmsConfiguration*, HwTools*); - bool publishPrices(EntsoeApi*); - bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishPrices(PriceService*); + bool publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea); bool publishRaw(String data); uint8_t getFormat(); diff --git a/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp b/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp index 82e655e1..2fb3ae02 100644 --- a/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp +++ b/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp @@ -7,7 +7,7 @@ #include "DomoticzMqttHandler.h" #include "json/domoticz_json.h" -bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { +bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) { bool ret = false; if (config.elidx > 0) { if(data->getActiveImportCounter() > 1.0) { @@ -73,11 +73,11 @@ bool DomoticzMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* return false; } -bool DomoticzMqttHandler::publishPrices(EntsoeApi* eapi) { +bool DomoticzMqttHandler::publishPrices(PriceService* ps) { return false; } -bool DomoticzMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { +bool DomoticzMqttHandler::publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea) { return false; } diff --git a/lib/EnergyAccounting/include/EnergyAccounting.h b/lib/EnergyAccounting/include/EnergyAccounting.h index 46af44ae..07e9da15 100644 --- a/lib/EnergyAccounting/include/EnergyAccounting.h +++ b/lib/EnergyAccounting/include/EnergyAccounting.h @@ -10,7 +10,7 @@ #include "Arduino.h" #include "AmsData.h" #include "AmsDataStorage.h" -#include "EntsoeApi.h" +#include "PriceService.h" struct EnergyAccountingPeak { uint8_t day; @@ -82,7 +82,7 @@ class EnergyAccounting { public: EnergyAccounting(RemoteDebug*, EnergyAccountingRealtimeData*); void setup(AmsDataStorage *ds, EnergyAccountingConfig *config); - void setEapi(EntsoeApi *eapi); + void setPriceService(PriceService *ps); void setTimezone(Timezone*); EnergyAccountingConfig* getConfig(); bool update(AmsData* amsData); @@ -126,7 +126,7 @@ private: RemoteDebug* debugger = NULL; bool init = false, initPrice = false; AmsDataStorage *ds = NULL; - EntsoeApi *eapi = NULL; + PriceService *ps = NULL; EnergyAccountingConfig *config = NULL; Timezone *tz = NULL; EnergyAccountingData data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/lib/EnergyAccounting/src/EnergyAccounting.cpp b/lib/EnergyAccounting/src/EnergyAccounting.cpp index 823e344b..95699a50 100644 --- a/lib/EnergyAccounting/src/EnergyAccounting.cpp +++ b/lib/EnergyAccounting/src/EnergyAccounting.cpp @@ -34,8 +34,8 @@ void EnergyAccounting::setup(AmsDataStorage *ds, EnergyAccountingConfig *config) this->config = config; } -void EnergyAccounting::setEapi(EntsoeApi *eapi) { - this->eapi = eapi; +void EnergyAccounting::setPriceService(PriceService *ps) { + this->ps = ps; } EnergyAccountingConfig* EnergyAccounting::getConfig() { @@ -92,7 +92,7 @@ bool EnergyAccounting::update(AmsData* amsData) { } float price = getPriceForHour(0); - if(!initPrice && price != ENTSOE_NO_VALUE) { + if(!initPrice && price != PRICE_NO_VALUE) { if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EnergyAccounting) Initializing prices at %lu\n"), (int32_t) now); calcDayCost(); } @@ -170,7 +170,7 @@ bool EnergyAccounting::update(AmsData* amsData) { if(kwhi > 0) { if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) Adding %.4f kWh import\n"), kwhi); this->realtimeData->use += kwhi; - if(price != ENTSOE_NO_VALUE) { + if(price != PRICE_NO_VALUE) { float cost = price * kwhi; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), cost / 100.0, currency.c_str()); this->realtimeData->costHour += cost; @@ -186,7 +186,7 @@ bool EnergyAccounting::update(AmsData* amsData) { if(kwhe > 0) { if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) Adding %.4f kWh export\n"), kwhe); this->realtimeData->produce += kwhe; - if(price != ENTSOE_NO_VALUE) { + if(price != PRICE_NO_VALUE) { float income = price * kwhe; if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), income / 100.0, currency.c_str()); this->realtimeData->incomeHour += income; @@ -211,14 +211,14 @@ void EnergyAccounting::calcDayCost() { if(tz == NULL) return; breakTime(tz->toLocal(now), local); - if(getPriceForHour(0) != ENTSOE_NO_VALUE) { + if(getPriceForHour(0) != PRICE_NO_VALUE) { if(initPrice) { this->realtimeData->costDay = 0; this->realtimeData->incomeDay = 0; } for(uint8_t i = 0; i < this->realtimeData->currentHour; i++) { float price = getPriceForHour(i - local.Hour); - if(price == ENTSOE_NO_VALUE) break; + if(price == PRICE_NO_VALUE) break; breakTime(now - ((local.Hour - i) * 3600), utc); int16_t wh = ds->getHourImport(utc.Hour); this->realtimeData->costDay += price * (wh / 1000.0); @@ -576,6 +576,6 @@ void EnergyAccounting::setFixedPrice(float price, String currency) { float EnergyAccounting::getPriceForHour(uint8_t h) { if(fixedPrice > 0.0) return fixedPrice; - if(eapi == NULL) return ENTSOE_NO_VALUE; - return eapi->getValueForHour(h); + if(ps == NULL) return PRICE_NO_VALUE; + return ps->getValueForHour(h); } \ No newline at end of file diff --git a/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h b/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h index 9da088b9..aac67733 100644 --- a/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h +++ b/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h @@ -58,10 +58,10 @@ public: discoveryTopic = F("homeassistant/sensor/"); } }; - bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); + bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps); bool publishTemperatures(AmsConfiguration*, HwTools*); - bool publishPrices(EntsoeApi*); - bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishPrices(PriceService*); + bool publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea); bool publishRaw(String data); uint8_t getFormat(); @@ -89,7 +89,7 @@ private: bool publishList3(AmsData* data, EnergyAccounting* ea); bool publishList4(AmsData* data, EnergyAccounting* ea); String getMeterModel(AmsData* data); - bool publishRealtime(AmsData* data, EnergyAccounting* ea, EntsoeApi* eapi); + bool publishRealtime(AmsData* data, EnergyAccounting* ea, PriceService* ps); void publishSensor(const HomeAssistantSensor& sensor); void publishList1Sensors(); void publishList1ExportSensors(); @@ -99,10 +99,10 @@ private: void publishList3ExportSensors(); void publishList4Sensors(); void publishList4ExportSensors(); - void publishRealtimeSensors(EnergyAccounting* ea, EntsoeApi* eapi); - void publishRealtimeExportSensors(EnergyAccounting* ea, EntsoeApi* eapi); + void publishRealtimeSensors(EnergyAccounting* ea, PriceService* ps); + void publishRealtimeExportSensors(EnergyAccounting* ea, PriceService* ps); void publishTemperatureSensor(uint8_t index, String id); - void publishPriceSensors(EntsoeApi* eapi); + void publishPriceSensors(PriceService* ps); void publishSystemSensors(); String boardTypeToString(uint8_t b) { diff --git a/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp b/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp index 38a1da3b..2814df1c 100644 --- a/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp +++ b/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp @@ -21,7 +21,7 @@ #include #endif -bool HomeAssistantMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { +bool HomeAssistantMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) { if(topic.isEmpty() || !mqtt.connected()) return false; @@ -40,7 +40,7 @@ bool HomeAssistantMqttHandler::publish(AmsData* data, AmsData* previousState, En loop(); if(ea->isInitialized()) { - publishRealtime(data, ea, eapi); + publishRealtime(data, ea, ps); loop(); } return true; @@ -125,9 +125,9 @@ String HomeAssistantMqttHandler::getMeterModel(AmsData* data) { return meterModel; } -bool HomeAssistantMqttHandler::publishRealtime(AmsData* data, EnergyAccounting* ea, EntsoeApi* eapi) { - publishRealtimeSensors(ea, eapi); - if(ea->getProducedThisHour() > 0.0 || ea->getProducedToday() > 0.0 || ea->getProducedThisMonth() > 0.0) publishRealtimeExportSensors(ea, eapi); +bool HomeAssistantMqttHandler::publishRealtime(AmsData* data, EnergyAccounting* ea, PriceService* ps) { + publishRealtimeSensors(ea, ps); + if(ea->getProducedThisHour() > 0.0 || ea->getProducedToday() > 0.0 || ea->getProducedThisMonth() > 0.0) publishRealtimeExportSensors(ea, ps); String peaks = ""; uint8_t peakCount = ea->getConfig()->hours; if(peakCount > 5) peakCount = 5; @@ -185,13 +185,13 @@ bool HomeAssistantMqttHandler::publishTemperatures(AmsConfiguration* config, HwT return ret; } -bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { +bool HomeAssistantMqttHandler::publishPrices(PriceService* ps) { if(topic.isEmpty() || !mqtt.connected()) return false; - if(eapi->getValueForHour(0) == ENTSOE_NO_VALUE) + if(ps->getValueForHour(0) == PRICE_NO_VALUE) return false; - publishPriceSensors(eapi); + publishPriceSensors(ps); time_t now = time(nullptr); @@ -199,12 +199,12 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { int8_t min1hrIdx = -1, min3hrIdx = -1, min6hrIdx = -1; float min = INT16_MAX, max = INT16_MIN; float values[38]; - for(int i = 0;i < 38; i++) values[i] = ENTSOE_NO_VALUE; + for(int i = 0;i < 38; i++) values[i] = PRICE_NO_VALUE; for(uint8_t i = 0; i < 38; i++) { - float val = eapi->getValueForHour(now, i); + float val = ps->getValueForHour(now, i); values[i] = val; - if(val == ENTSOE_NO_VALUE) break; + if(val == PRICE_NO_VALUE) break; if(val < min) min = val; if(val > max) max = val; @@ -219,7 +219,7 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { float val1 = values[i++]; float val2 = values[i++]; float val3 = val; - if(val1 == ENTSOE_NO_VALUE || val2 == ENTSOE_NO_VALUE || val3 == ENTSOE_NO_VALUE) continue; + if(val1 == PRICE_NO_VALUE || val2 == PRICE_NO_VALUE || val3 == PRICE_NO_VALUE) continue; float val3hr = val1+val2+val3; if(min3hrIdx == -1 || min3hr > val3hr) { min3hr = val3hr; @@ -235,7 +235,7 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { float val4 = values[i++]; float val5 = values[i++]; float val6 = val; - if(val1 == ENTSOE_NO_VALUE || val2 == ENTSOE_NO_VALUE || val3 == ENTSOE_NO_VALUE || val4 == ENTSOE_NO_VALUE || val5 == ENTSOE_NO_VALUE || val6 == ENTSOE_NO_VALUE) continue; + if(val1 == PRICE_NO_VALUE || val2 == PRICE_NO_VALUE || val3 == PRICE_NO_VALUE || val4 == PRICE_NO_VALUE || val5 == PRICE_NO_VALUE || val6 == PRICE_NO_VALUE) continue; float val6hr = val1+val2+val3+val4+val5+val6; if(min6hrIdx == -1 || min6hr > val6hr) { min6hr = val6hr; @@ -321,7 +321,7 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { return ret; } -bool HomeAssistantMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { +bool HomeAssistantMqttHandler::publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea) { if(topic.isEmpty() || !mqtt.connected()) return false; @@ -434,13 +434,13 @@ void HomeAssistantMqttHandler::publishList4ExportSensors() { l4eInit = true; } -void HomeAssistantMqttHandler::publishRealtimeSensors(EnergyAccounting* ea, EntsoeApi* eapi) { +void HomeAssistantMqttHandler::publishRealtimeSensors(EnergyAccounting* ea, PriceService* ps) { if(rtInit) return; for(uint8_t i = 0; i < RealtimeSensorCount; i++) { HomeAssistantSensor sensor = RealtimeSensors[i]; if(strncmp_P(sensor.devcl, PSTR("monetary"), 8) == 0) { - if(eapi == NULL) continue; - sensor.uom = eapi->getCurrency(); + if(ps == NULL) continue; + sensor.uom = ps->getCurrency(); } publishSensor(sensor); } @@ -464,13 +464,13 @@ void HomeAssistantMqttHandler::publishRealtimeSensors(EnergyAccounting* ea, Ents rtInit = true; } -void HomeAssistantMqttHandler::publishRealtimeExportSensors(EnergyAccounting* ea, EntsoeApi* eapi) { +void HomeAssistantMqttHandler::publishRealtimeExportSensors(EnergyAccounting* ea, PriceService* ps) { if(rteInit) return; for(uint8_t i = 0; i < RealtimeExportSensorCount; i++) { HomeAssistantSensor sensor = RealtimeExportSensors[i]; if(strncmp_P(sensor.devcl, PSTR("monetary"), 8) == 0) { - if(eapi == NULL) continue; - sensor.uom = eapi->getCurrency(); + if(ps == NULL) continue; + sensor.uom = ps->getCurrency(); } publishSensor(sensor); } @@ -501,9 +501,9 @@ void HomeAssistantMqttHandler::publishTemperatureSensor(uint8_t index, String id tInit[index] = true; } -void HomeAssistantMqttHandler::publishPriceSensors(EntsoeApi* eapi) { - if(eapi == NULL) return; - String uom = String(eapi->getCurrency()) + "/kWh"; +void HomeAssistantMqttHandler::publishPriceSensors(PriceService* ps) { + if(ps == NULL) return; + String uom = String(ps->getCurrency()) + "/kWh"; if(!pInit) { for(uint8_t i = 0; i < PriceSensorCount; i++) { @@ -517,8 +517,8 @@ void HomeAssistantMqttHandler::publishPriceSensors(EntsoeApi* eapi) { } for(uint8_t i = 0; i < 38; i++) { if(prInit[i]) continue; - float val = eapi->getValueForHour(i); - if(val == ENTSOE_NO_VALUE) continue; + float val = ps->getValueForHour(i); + if(val == PRICE_NO_VALUE) continue; char name[strlen(PriceSensor.name)+2]; snprintf(name, strlen(PriceSensor.name)+2, PriceSensor.name, i, i == 1 ? "hour" : "hours"); diff --git a/lib/JsonMqttHandler/include/JsonMqttHandler.h b/lib/JsonMqttHandler/include/JsonMqttHandler.h index d2b5cd22..c477eb2c 100644 --- a/lib/JsonMqttHandler/include/JsonMqttHandler.h +++ b/lib/JsonMqttHandler/include/JsonMqttHandler.h @@ -14,10 +14,10 @@ public: JsonMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf, HwTools* hw) : AmsMqttHandler(mqttConfig, debugger, buf) { this->hw = hw; }; - bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); + bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps); bool publishTemperatures(AmsConfiguration*, HwTools*); - bool publishPrices(EntsoeApi*); - bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishPrices(PriceService*); + bool publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea); bool publishRaw(String data); uint8_t getFormat(); diff --git a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp index fb1fd980..3edb15e1 100644 --- a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp +++ b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp @@ -15,7 +15,7 @@ #include "json/jsonsys_json.h" #include "json/jsonprices_json.h" -bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { +bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) { if(strlen(mqttConfig.publishTopic) == 0) { if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Unable to publish data, no publish topic\n")); return false; @@ -209,10 +209,10 @@ bool JsonMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw) return ret; } -bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { +bool JsonMqttHandler::publishPrices(PriceService* ps) { if(strlen(mqttConfig.publishTopic) == 0 || !mqtt.connected()) return false; - if(eapi->getValueForHour(0) == ENTSOE_NO_VALUE) + if(ps->getValueForHour(0) == PRICE_NO_VALUE) return false; time_t now = time(nullptr); @@ -221,12 +221,12 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { int8_t min1hrIdx = -1, min3hrIdx = -1, min6hrIdx = -1; float min = INT16_MAX, max = INT16_MIN; float values[38]; - for(int i = 0;i < 38; i++) values[i] = ENTSOE_NO_VALUE; + for(int i = 0;i < 38; i++) values[i] = PRICE_NO_VALUE; for(uint8_t i = 0; i < 38; i++) { - float val = eapi->getValueForHour(now, i); + float val = ps->getValueForHour(now, i); values[i] = val; - if(val == ENTSOE_NO_VALUE) break; + if(val == PRICE_NO_VALUE) break; if(val < min) min = val; if(val > max) max = val; @@ -241,7 +241,7 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { float val1 = values[i++]; float val2 = values[i++]; float val3 = val; - if(val1 == ENTSOE_NO_VALUE || val2 == ENTSOE_NO_VALUE || val3 == ENTSOE_NO_VALUE) continue; + if(val1 == PRICE_NO_VALUE || val2 == PRICE_NO_VALUE || val3 == PRICE_NO_VALUE) continue; float val3hr = val1+val2+val3; if(min3hrIdx == -1 || min3hr > val3hr) { min3hr = val3hr; @@ -257,7 +257,7 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { float val4 = values[i++]; float val5 = values[i++]; float val6 = val; - if(val1 == ENTSOE_NO_VALUE || val2 == ENTSOE_NO_VALUE || val3 == ENTSOE_NO_VALUE || val4 == ENTSOE_NO_VALUE || val5 == ENTSOE_NO_VALUE || val6 == ENTSOE_NO_VALUE) continue; + if(val1 == PRICE_NO_VALUE || val2 == PRICE_NO_VALUE || val3 == PRICE_NO_VALUE || val4 == PRICE_NO_VALUE || val5 == PRICE_NO_VALUE || val6 == PRICE_NO_VALUE) continue; float val6hr = val1+val2+val3+val4+val5+val6; if(min6hrIdx == -1 || min6hr > val6hr) { min6hr = val6hr; @@ -343,7 +343,7 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { return ret; } -bool JsonMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { +bool JsonMqttHandler::publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea) { if(strlen(mqttConfig.publishTopic) == 0 || !mqtt.connected()) return false; diff --git a/lib/EntsoePriceApi/include/DnbCurrParser.h b/lib/PriceService/include/DnbCurrParser.h similarity index 100% rename from lib/EntsoePriceApi/include/DnbCurrParser.h rename to lib/PriceService/include/DnbCurrParser.h diff --git a/lib/EntsoePriceApi/include/EntsoeA44Parser.h b/lib/PriceService/include/EntsoeA44Parser.h similarity index 96% rename from lib/EntsoePriceApi/include/EntsoeA44Parser.h rename to lib/PriceService/include/EntsoeA44Parser.h index 3a96aad9..30bf0da6 100644 --- a/lib/EntsoePriceApi/include/EntsoeA44Parser.h +++ b/lib/PriceService/include/EntsoeA44Parser.h @@ -16,8 +16,6 @@ #define DOCPOS_POSITION 3 #define DOCPOS_AMOUNT 4 -#define ENTSOE_NO_VALUE -127 - class EntsoeA44Parser: public Stream { public: EntsoeA44Parser(); diff --git a/lib/EntsoePriceApi/include/EntsoeApi.h b/lib/PriceService/include/PriceService.h similarity index 89% rename from lib/EntsoePriceApi/include/EntsoeApi.h rename to lib/PriceService/include/PriceService.h index 2f4fd28f..7dea9094 100644 --- a/lib/EntsoePriceApi/include/EntsoeApi.h +++ b/lib/PriceService/include/PriceService.h @@ -4,8 +4,8 @@ * */ -#ifndef _ENTSOEAPI_H -#define _ENTSOEAPI_H +#ifndef _PRICESERVICE_H +#define _PRICESERVICE_H #include "TimeLib.h" #include "Timezone.h" @@ -23,10 +23,10 @@ #define SSL_BUF_SIZE 512 -class EntsoeApi { +class PriceService { public: - EntsoeApi(RemoteDebug*); - void setup(EntsoeConfig&); + PriceService(RemoteDebug*); + void setup(PriceServiceConfig&); bool loop(); char* getToken(); @@ -40,7 +40,7 @@ public: private: RemoteDebug* debugger; - EntsoeConfig* config = NULL; + PriceServiceConfig* config = NULL; HTTPClient* http = NULL; uint8_t currentDay = 0, currentHour = 0; diff --git a/lib/EntsoePriceApi/include/PricesContainer.h b/lib/PriceService/include/PricesContainer.h similarity index 89% rename from lib/EntsoePriceApi/include/PricesContainer.h rename to lib/PriceService/include/PricesContainer.h index 89671bcf..0bd35bde 100644 --- a/lib/EntsoePriceApi/include/PricesContainer.h +++ b/lib/PriceService/include/PricesContainer.h @@ -6,6 +6,9 @@ #ifndef _PRICESCONTAINER_H #define _PRICESCONTAINER_H + +#define PRICE_NO_VALUE -127 + struct PricesContainer { char currency[4]; char measurementUnit[4]; diff --git a/lib/EntsoePriceApi/src/DnbCurrParser.cpp b/lib/PriceService/src/DnbCurrParser.cpp similarity index 100% rename from lib/EntsoePriceApi/src/DnbCurrParser.cpp rename to lib/PriceService/src/DnbCurrParser.cpp diff --git a/lib/EntsoePriceApi/src/EntsoeA44Parser.cpp b/lib/PriceService/src/EntsoeA44Parser.cpp similarity index 93% rename from lib/EntsoePriceApi/src/EntsoeA44Parser.cpp rename to lib/PriceService/src/EntsoeA44Parser.cpp index d7c6247a..ec326d36 100644 --- a/lib/EntsoePriceApi/src/EntsoeA44Parser.cpp +++ b/lib/PriceService/src/EntsoeA44Parser.cpp @@ -8,7 +8,7 @@ #include "HardwareSerial.h" EntsoeA44Parser::EntsoeA44Parser() { - for(int i = 0; i < 25; i++) points[i] = ENTSOE_NO_VALUE; + for(int i = 0; i < 25; i++) points[i] = PRICE_NO_VALUE; } EntsoeA44Parser::~EntsoeA44Parser() { @@ -24,7 +24,7 @@ char* EntsoeA44Parser::getMeasurementUnit() { } float EntsoeA44Parser::getPoint(uint8_t position) { - if(position >= 25) return ENTSOE_NO_VALUE; + if(position >= 25) return PRICE_NO_VALUE; return points[position]; } @@ -121,6 +121,6 @@ void EntsoeA44Parser::get(PricesContainer* container) { strcpy(container->source, "EOE"); for(uint8_t i = 0; i < 25; i++) { - container->points[i] = points[i] == ENTSOE_NO_VALUE ? ENTSOE_NO_VALUE : points[i] * 10000; + container->points[i] = points[i] == PRICE_NO_VALUE ? PRICE_NO_VALUE : points[i] * 10000; } } \ No newline at end of file diff --git a/lib/EntsoePriceApi/src/EntsoeApi.cpp b/lib/PriceService/src/PriceService.cpp similarity index 85% rename from lib/EntsoePriceApi/src/EntsoeApi.cpp rename to lib/PriceService/src/PriceService.cpp index 8e931141..2ce99bb9 100644 --- a/lib/EntsoePriceApi/src/EntsoeApi.cpp +++ b/lib/PriceService/src/PriceService.cpp @@ -4,7 +4,7 @@ * */ -#include "EntsoeApi.h" +#include "PriceService.h" #include #include "Uptime.h" #include "TimeLib.h" @@ -17,7 +17,7 @@ #include #endif -EntsoeApi::EntsoeApi(RemoteDebug* Debug) { +PriceService::PriceService(RemoteDebug* Debug) { this->buf = (char*) malloc(BufferSize); debugger = Debug; @@ -30,9 +30,9 @@ EntsoeApi::EntsoeApi(RemoteDebug* Debug) { tomorrowFetchMinute = 15 + random(45); // Random between 13:15 and 14:00 } -void EntsoeApi::setup(EntsoeConfig& config) { +void PriceService::setup(PriceServiceConfig& config) { if(this->config == NULL) { - this->config = new EntsoeConfig(); + this->config = new PriceServiceConfig(); } memcpy(this->config, &config, sizeof(config)); lastTodayFetch = lastTomorrowFetch = lastCurrencyFetch = 0; @@ -64,19 +64,19 @@ void EntsoeApi::setup(EntsoeConfig& config) { } -char* EntsoeApi::getToken() { - return this->config->token; +char* PriceService::getToken() { + return this->config->entsoeToken; } -char* EntsoeApi::getCurrency() { +char* PriceService::getCurrency() { return this->config->currency; } -char* EntsoeApi::getArea() { +char* PriceService::getArea() { return this->config->area; } -char* EntsoeApi::getSource() { +char* PriceService::getSource() { if(this->today != NULL && this->tomorrow != NULL) { if(strcmp(this->today->source, this->tomorrow->source) == 0) { return this->today->source; @@ -91,12 +91,12 @@ char* EntsoeApi::getSource() { return ""; } -float EntsoeApi::getValueForHour(int8_t hour) { +float PriceService::getValueForHour(int8_t hour) { time_t cur = time(nullptr); return getValueForHour(cur, hour); } -float EntsoeApi::getValueForHour(time_t ts, int8_t hour) { +float PriceService::getValueForHour(time_t ts, int8_t hour) { tmElements_t tm; int8_t pos = hour; @@ -114,47 +114,47 @@ float EntsoeApi::getValueForHour(time_t ts, int8_t hour) { hoursToday++; } if(pos > 49) - return ENTSOE_NO_VALUE; + return PRICE_NO_VALUE; - float value = ENTSOE_NO_VALUE; + float value = PRICE_NO_VALUE; float multiplier = config->multiplier / 1000.0; if(pos >= hoursToday) { if(tomorrow == NULL) - return ENTSOE_NO_VALUE; - if(tomorrow->points[pos-hoursToday] == ENTSOE_NO_VALUE) - return ENTSOE_NO_VALUE; + return PRICE_NO_VALUE; + if(tomorrow->points[pos-hoursToday] == PRICE_NO_VALUE) + return PRICE_NO_VALUE; value = tomorrow->points[pos-hoursToday] / 10000.0; if(strcmp(tomorrow->measurementUnit, "KWH") == 0) { // Multiplier is 1 } else if(strcmp(tomorrow->measurementUnit, "MWH") == 0) { multiplier *= 0.001; } else { - return ENTSOE_NO_VALUE; + return PRICE_NO_VALUE; } float mult = getCurrencyMultiplier(tomorrow->currency, config->currency, time(nullptr)); - if(mult == 0) return ENTSOE_NO_VALUE; + if(mult == 0) return PRICE_NO_VALUE; multiplier *= mult; } else if(pos >= 0) { if(today == NULL) - return ENTSOE_NO_VALUE; - if(today->points[pos] == ENTSOE_NO_VALUE) - return ENTSOE_NO_VALUE; + return PRICE_NO_VALUE; + if(today->points[pos] == PRICE_NO_VALUE) + return PRICE_NO_VALUE; value = today->points[pos] / 10000.0; if(strcmp(today->measurementUnit, "KWH") == 0) { // Multiplier is 1 } else if(strcmp(today->measurementUnit, "MWH") == 0) { multiplier *= 0.001; } else { - return ENTSOE_NO_VALUE; + return PRICE_NO_VALUE; } float mult = getCurrencyMultiplier(today->currency, config->currency, time(nullptr)); - if(mult == 0) return ENTSOE_NO_VALUE; + if(mult == 0) return PRICE_NO_VALUE; multiplier *= mult; } return value * multiplier; } -bool EntsoeApi::loop() { +bool PriceService::loop() { uint64_t now = millis64(); if(now < 10000) return false; // Grace period @@ -182,7 +182,7 @@ bool EntsoeApi::loop() { } if(currentDay != tm.Day) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Rotating price objects at %lu\n"), t); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(PriceService) Rotating price objects at %lu\n"), t); if(today != NULL) delete today; if(tomorrow != NULL) { today = tomorrow; @@ -231,7 +231,7 @@ bool EntsoeApi::loop() { return false; } -bool EntsoeApi::retrieve(const char* url, Stream* doc) { +bool PriceService::retrieve(const char* url, Stream* doc) { #if defined(ESP32) if(http->begin(url)) { if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Connection established\n")); @@ -266,7 +266,7 @@ bool EntsoeApi::retrieve(const char* url, Stream* doc) { } else { nextFetchDelayMinutes = 2; } - if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(EntsoeApi) Communication error, returned status: %d\n"), status); + if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(PriceService) Communication error, returned status: %d\n"), status); if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(http->errorToString(status).c_str()); if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(http->getString().c_str()); @@ -280,7 +280,7 @@ bool EntsoeApi::retrieve(const char* url, Stream* doc) { return false; } -float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t t) { +float PriceService::getCurrencyMultiplier(const char* from, const char* to, time_t t) { if(strcmp(from, to) == 0) return 1.00; @@ -297,17 +297,17 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t #endif snprintf_P(buf, BufferSize, PSTR("https://data.norges-bank.no/api/data/EXR/B.%s.NOK.SP?lastNObservations=1"), from); - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Retrieving %s to NOK conversion\n"), from); - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(PriceService) Retrieving %s to NOK conversion\n"), from); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) url: %s\n"), buf); if(retrieve(buf, &p)) { - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) got exchange rate %.4f\n"), p.getValue()); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) got exchange rate %.4f\n"), p.getValue()); currencyMultiplier = p.getValue(); if(strncmp(to, "NOK", 3) != 0) { snprintf_P(buf, BufferSize, PSTR("https://data.norges-bank.no/api/data/EXR/B.%s.NOK.SP?lastNObservations=1"), to); - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Retrieving %s to NOK conversion\n"), to); - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(PriceService) Retrieving %s to NOK conversion\n"), to); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) url: %s\n"), buf); if(retrieve(buf, &p)) { - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) got exchange rate %.4f\n"), p.getValue()); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) got exchange rate %.4f\n"), p.getValue()); currencyMultiplier /= p.getValue(); } else { currencyMultiplier = 0; @@ -318,7 +318,7 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t currencyMultiplier = 0; return 0; } - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) Resulting currency multiplier: %.4f\n"), currencyMultiplier); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) Resulting currency multiplier: %.4f\n"), currencyMultiplier); tmElements_t tm; breakTime(t, tm); lastCurrencyFetch = now + (SECS_PER_DAY * 1000) - (((((tm.Hour * 60) + tm.Minute) * 60) + tm.Second) * 1000) + 3600000; @@ -326,7 +326,7 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t return currencyMultiplier; } -PricesContainer* EntsoeApi::fetchPrices(time_t t) { +PricesContainer* PriceService::fetchPrices(time_t t) { if(strlen(getToken()) > 0) { tmElements_t tm; breakTime(tz->toLocal(t), tm); @@ -348,10 +348,10 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) { ESP.wdtFeed(); #endif - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Fetching prices for %d.%d.%d\n"), tm.Day, tm.Month, tm.Year+1970); - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(PriceService) Fetching prices for %d.%d.%d\n"), tm.Day, tm.Month, tm.Year+1970); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) url: %s\n"), buf); EntsoeA44Parser a44; - if(retrieve(buf, &a44) && a44.getPoint(0) != ENTSOE_NO_VALUE) { + if(retrieve(buf, &a44) && a44.getPoint(0) != PRICE_NO_VALUE) { PricesContainer* ret = new PricesContainer(); a44.get(ret); return ret; @@ -405,10 +405,10 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) { debugPrint(content, 0, data.length()); } if(gcmRet > 0) { - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) Price data starting at: %d\n"), gcmRet); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(PriceService) Price data starting at: %d\n"), gcmRet); PricesContainer* ret = new PricesContainer(); for(uint8_t i = 0; i < 25; i++) { - ret->points[i] = ENTSOE_NO_VALUE; + ret->points[i] = PRICE_NO_VALUE; } memcpy(ret, content+gcmRet, sizeof(*ret)); for(uint8_t i = 0; i < 25; i++) { @@ -420,7 +420,7 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) { } else { lastError = gcmRet; nextFetchDelayMinutes = 60; - if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(EntsoeApi) Error code while decrypting prices: %d\n"), gcmRet); + if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(PriceService) Error code while decrypting prices: %d\n"), gcmRet); } } else { lastError = status; @@ -431,7 +431,7 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) { } else { nextFetchDelayMinutes = 5; } - if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(EntsoeApi) Communication error, returned status: %d\n"), status); + if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(PriceService) Communication error, returned status: %d\n"), status); if(debugger->isActive(RemoteDebug::ERROR)) { debugger->printf(http->errorToString(status).c_str()); debugger->println(); @@ -445,7 +445,7 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) { return NULL; } -void EntsoeApi::debugPrint(byte *buffer, int start, int length) { +void PriceService::debugPrint(byte *buffer, int start, int length) { for (int i = start; i < start + length; i++) { if (buffer[i] < 0x10) debugger->print(F("0")); @@ -461,6 +461,6 @@ void EntsoeApi::debugPrint(byte *buffer, int start, int length) { debugger->println(F("")); } -int16_t EntsoeApi::getLastError() { +int16_t PriceService::getLastError() { return lastError; } \ No newline at end of file diff --git a/lib/RawMqttHandler/include/RawMqttHandler.h b/lib/RawMqttHandler/include/RawMqttHandler.h index fd2500c2..b6ccfb6c 100644 --- a/lib/RawMqttHandler/include/RawMqttHandler.h +++ b/lib/RawMqttHandler/include/RawMqttHandler.h @@ -15,10 +15,10 @@ public: full = mqttConfig.payloadFormat == 2; topic = String(mqttConfig.publishTopic); }; - bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); + bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps); bool publishTemperatures(AmsConfiguration*, HwTools*); - bool publishPrices(EntsoeApi*); - bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishPrices(PriceService*); + bool publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea); bool publishRaw(String data); uint8_t getFormat(); diff --git a/lib/RawMqttHandler/src/RawMqttHandler.cpp b/lib/RawMqttHandler/src/RawMqttHandler.cpp index 70c4a300..d618df87 100644 --- a/lib/RawMqttHandler/src/RawMqttHandler.cpp +++ b/lib/RawMqttHandler/src/RawMqttHandler.cpp @@ -8,7 +8,7 @@ #include "hexutils.h" #include "Uptime.h" -bool RawMqttHandler::publish(AmsData* data, AmsData* meterState, EnergyAccounting* ea, EntsoeApi* eapi) { +bool RawMqttHandler::publish(AmsData* data, AmsData* meterState, EnergyAccounting* ea, PriceService* ps) { if(topic.isEmpty() || !mqtt.connected()) return false; @@ -158,10 +158,10 @@ bool RawMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw) return c > 0; } -bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { +bool RawMqttHandler::publishPrices(PriceService* ps) { if(topic.isEmpty() || !mqtt.connected()) return false; - if(eapi->getValueForHour(0) == ENTSOE_NO_VALUE) + if(ps->getValueForHour(0) == PRICE_NO_VALUE) return false; time_t now = time(nullptr); @@ -170,13 +170,13 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { int8_t min1hrIdx = -1, min3hrIdx = -1, min6hrIdx = -1; float min = INT16_MAX, max = INT16_MIN; float values[34]; - for(int i = 0;i < 34; i++) values[i] = ENTSOE_NO_VALUE; + for(int i = 0;i < 34; i++) values[i] = PRICE_NO_VALUE; for(uint8_t i = 0; i < 34; i++) { - float val = eapi->getValueForHour(now, i); + float val = ps->getValueForHour(now, i); values[i] = val; if(i > 23) continue; - if(val == ENTSOE_NO_VALUE) break; + if(val == PRICE_NO_VALUE) break; if(val < min) min = val; if(val > max) max = val; @@ -191,7 +191,7 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { float val1 = values[i++]; float val2 = values[i++]; float val3 = val; - if(val1 == ENTSOE_NO_VALUE || val2 == ENTSOE_NO_VALUE || val3 == ENTSOE_NO_VALUE) continue; + if(val1 == PRICE_NO_VALUE || val2 == PRICE_NO_VALUE || val3 == PRICE_NO_VALUE) continue; float val3hr = val1+val2+val3; if(min3hrIdx == -1 || min3hr > val3hr) { min3hr = val3hr; @@ -207,7 +207,7 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { float val4 = values[i++]; float val5 = values[i++]; float val6 = val; - if(val1 == ENTSOE_NO_VALUE || val2 == ENTSOE_NO_VALUE || val3 == ENTSOE_NO_VALUE || val4 == ENTSOE_NO_VALUE || val5 == ENTSOE_NO_VALUE || val6 == ENTSOE_NO_VALUE) continue; + if(val1 == PRICE_NO_VALUE || val2 == PRICE_NO_VALUE || val3 == PRICE_NO_VALUE || val4 == PRICE_NO_VALUE || val5 == PRICE_NO_VALUE || val6 == PRICE_NO_VALUE) continue; float val6hr = val1+val2+val3+val4+val5+val6; if(min6hrIdx == -1 || min6hr > val6hr) { min6hr = val6hr; @@ -241,7 +241,7 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { for(int i = 0; i < 34; i++) { float val = values[i]; - if(val == ENTSOE_NO_VALUE) { + if(val == PRICE_NO_VALUE) { mqtt.publish(topic + "/price/" + String(i), "", true, 0); } else { mqtt.publish(topic + "/price/" + String(i), String(val, 4), true, 0); @@ -268,7 +268,7 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { return true; } -bool RawMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { +bool RawMqttHandler::publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea) { if(topic.isEmpty() || !mqtt.connected()) return false; diff --git a/lib/SvelteUi/app/dist/index.js b/lib/SvelteUi/app/dist/index.js index 5a69c341..edfdd197 100644 --- a/lib/SvelteUi/app/dist/index.js +++ b/lib/SvelteUi/app/dist/index.js @@ -1,7 +1,7 @@ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const u of o.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&n(u)}).observe(document,{childList:!0,subtree:!0});function l(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=l(i);fetch(i.href,o)}})();function _e(){}function sl(t,e){for(const l in e)t[l]=e[l];return t}function tc(t){return t()}function wa(){return Object.create(null)}function Ge(t){t.forEach(tc)}function co(t){return typeof t=="function"}function $e(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let ps;function Xs(t,e){return ps||(ps=document.createElement("a")),ps.href=e,t===ps.href}function t0(t){return Object.keys(t).length===0}function mo(t,...e){if(t==null)return _e;const l=t.subscribe(...e);return l.unsubscribe?()=>l.unsubscribe():l}function ri(t){let e;return mo(t,l=>e=l)(),e}function _l(t,e,l){t.$$.on_destroy.push(mo(e,l))}function po(t,e,l,n){if(t){const i=lc(t,e,l,n);return t[0](i)}}function lc(t,e,l,n){return t[1]&&n?sl(l.ctx.slice(),t[1](n(e))):l.ctx}function _o(t,e,l,n){if(t[2]&&n){const i=t[2](n(l));if(e.dirty===void 0)return i;if(typeof i=="object"){const o=[],u=Math.max(e.dirty.length,i.length);for(let a=0;a32){const e=[],l=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,l,n)}function Ms(t){return function(e){return e.preventDefault(),t.call(this,e)}}function r(t,e,l){l==null?t.removeAttribute(e):t.getAttribute(e)!==l&&t.setAttribute(e,l)}const n0=["width","height"];function ai(t,e){const l=Object.getOwnPropertyDescriptors(t.__proto__);for(const n in e)e[n]==null?t.removeAttribute(n):n==="style"?t.style.cssText=e[n]:n==="__value"?t.value=t[n]=e[n]:l[n]&&l[n].set&&n0.indexOf(n)===-1?t[n]=e[n]:r(t,n,e[n])}function he(t){return t===""?null:+t}function i0(t){return Array.from(t.childNodes)}function X(t,e){e=""+e,t.data!==e&&(t.data=e)}function s0(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function o0(t,e,l){~l0.indexOf(l)?s0(t,e):X(t,e)}function ne(t,e){t.value=e??""}function nc(t,e,l,n){l==null?t.style.removeProperty(e):t.style.setProperty(e,l,n?"important":"")}function Te(t,e,l){for(let n=0;n{u.source===n.contentWindow&&e()})):(n.src="about:blank",n.onload=()=>{o=le(n.contentWindow,"resize",e),e()}),s(t,n),()=>{(i||o&&n.contentWindow)&&o(),y(n)}}function a0(t,e,{bubbles:l=!1,cancelable:n=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(t,l,n,e),i}function ya(t,e){return new t(e)}let Ti;function Ci(t){Ti=t}function Si(){if(!Ti)throw new Error("Function called outside component initialization");return Ti}function sc(t){Si().$$.on_mount.push(t)}function u0(t){Si().$$.on_destroy.push(t)}function f0(){const t=Si();return(e,l,{cancelable:n=!1}={})=>{const i=t.$$.callbacks[e];if(i){const o=a0(e,l,{cancelable:n});return i.slice().forEach(u=>{u.call(t,o)}),!o.defaultPrevented}return!0}}function Mi(t,e){return Si().$$.context.set(t,e),e}function Hl(t){return Si().$$.context.get(t)}const ni=[],ks=[];let ii=[];const Ca=[],oc=Promise.resolve();let Zs=!1;function rc(){Zs||(Zs=!0,oc.then(ac))}function c0(){return rc(),oc}function Ke(t){ii.push(t)}const zs=new Set;let ti=0;function ac(){if(ti!==0)return;const t=Ti;do{try{for(;tit.indexOf(n)===-1?e.push(n):l.push(n)),l.forEach(n=>n()),ii=e}const hs=new Set;let rn;function Ie(){rn={r:0,c:[],p:rn}}function Oe(){rn.r||Ge(rn.c),rn=rn.p}function O(t,e){t&&t.i&&(hs.delete(t),t.i(e))}function B(t,e,l,n){if(t&&t.o){if(hs.has(t))return;hs.add(t),rn.c.push(()=>{hs.delete(t),n&&(l&&t.d(1),n())}),t.o(e)}else n&&n()}function uc(t,e){const l={},n={},i={$$scope:1};let o=t.length;for(;o--;){const u=t[o],a=e[o];if(a){for(const f in u)f in a||(n[f]=1);for(const f in a)i[f]||(l[f]=a[f],i[f]=1);t[o]=a}else for(const f in u)i[f]=1}for(const u in n)u in l||(l[u]=void 0);return l}function Ma(t){return typeof t=="object"&&t!==null?t:{}}function re(t){t&&t.c()}function se(t,e,l,n){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,l),n||Ke(()=>{const u=t.$$.on_mount.map(tc).filter(co);t.$$.on_destroy?t.$$.on_destroy.push(...u):Ge(u),t.$$.on_mount=[]}),o.forEach(Ke)}function oe(t,e){const l=t.$$;l.fragment!==null&&(p0(l.after_update),Ge(l.on_destroy),l.fragment&&l.fragment.d(e),l.on_destroy=l.fragment=null,l.ctx=[])}function _0(t,e){t.$$.dirty[0]===-1&&(ni.push(t),rc(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const v=d.length?d[0]:h;return c.ctx&&i(c.ctx[_],c.ctx[_]=v)&&(!c.skip_bound&&c.bound[_]&&c.bound[_](v),p&&_0(t,_)),h}):[],c.update(),p=!0,Ge(c.before_update),c.fragment=n?n(c.ctx):!1,e.target){if(e.hydrate){const _=i0(e.target);c.fragment&&c.fragment.l(_),_.forEach(y)}else c.fragment&&c.fragment.c();e.intro&&O(t.$$.fragment),se(t,e.target,e.anchor,e.customElement),ac()}Ci(f)}class De{$destroy(){oe(this,1),this.$destroy=_e}$on(e,l){if(!co(l))return _e;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(l),()=>{const i=n.indexOf(l);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!t0(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ta=t=>typeof t>"u",fc=t=>typeof t=="function",cc=t=>typeof t=="number";function d0(t){return!t.defaultPrevented&&t.button===0&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function mc(){let t=0;return()=>t++}function v0(){return Math.random().toString(36).substring(2)}const Wl=typeof window>"u";function pc(t,e,l){return t.addEventListener(e,l),()=>t.removeEventListener(e,l)}const _c=(t,e)=>t?{}:{style:e},Js=t=>({"aria-hidden":"true",..._c(t,"display:none;")}),li=[];function dc(t,e){return{subscribe:it(t,e).subscribe}}function it(t,e=_e){let l;const n=new Set;function i(a){if($e(t,a)&&(t=a,l)){const f=!li.length;for(const c of n)c[1](),li.push(c,t);if(f){for(let c=0;c{n.delete(c),n.size===0&&l&&(l(),l=null)}}return{set:i,update:o,subscribe:u}}function h0(t,e,l){const n=!Array.isArray(t),i=n?[t]:t,o=e.length<2;return dc(l,u=>{let a=!1;const f=[];let c=0,p=_e;const _=()=>{if(c)return;p();const d=e(n?f[0]:f,u);o?u(d):p=co(d)?d:_e},h=i.map((d,v)=>mo(d,g=>{f[v]=g,c&=~(1<{c|=1<`@@svnav-ctx__${t}`,xs=$i("LOCATION"),ui=$i("ROUTER"),vc=$i("ROUTE"),b0=$i("ROUTE_PARAMS"),g0=$i("FOCUS_ELEM"),hc=/^:(.+)/,ki=(t,e,l)=>t.substr(e,l),eo=(t,e)=>ki(t,0,e.length)===e,k0=t=>t==="",w0=t=>hc.test(t),bc=t=>t[0]==="*",y0=t=>t.replace(/\*.*$/,""),gc=t=>t.replace(/(^\/+|\/+$)/g,"");function vl(t,e=!1){const l=gc(t).split("/");return e?l.filter(Boolean):l}const Gs=(t,e)=>t+(e?`?${e}`:""),bo=t=>`/${gc(t)}`;function Ni(...t){const e=n=>vl(n,!0).join("/"),l=t.map(e).join("/");return bo(l)}const go=1,Ts=2,mn=3,C0=4,kc=5,M0=6,wc=7,T0=8,S0=9,yc=10,Cc=11,$0={[go]:"Link",[Ts]:"Route",[mn]:"Router",[C0]:"useFocus",[kc]:"useLocation",[M0]:"useMatch",[wc]:"useNavigate",[T0]:"useParams",[S0]:"useResolvable",[yc]:"useResolve",[Cc]:"navigate"},ko=t=>$0[t];function N0(t,e){let l;return t===Ts?l=e.path?`path="${e.path}"`:"default":t===go?l=`to="${e.to}"`:t===mn&&(l=`basepath="${e.basepath||""}"`),`<${ko(t)} ${l||""} />`}function E0(t,e,l,n){const i=l&&N0(n||t,l),o=i?` Occurred in: ${i}`:"",u=ko(t),a=fc(e)?e(u):e;return`<${u}> ${a}${o}`}const Mc=t=>(...e)=>t(E0(...e)),Tc=Mc(t=>{throw new Error(t)}),ws=Mc(console.warn),Sa=4,A0=3,P0=2,D0=1,I0=1;function O0(t,e){const l=t.default?0:vl(t.fullPath).reduce((n,i)=>{let o=n;return o+=Sa,k0(i)?o+=I0:w0(i)?o+=P0:bc(i)?o-=Sa+D0:o+=A0,o},0);return{route:t,score:l,index:e}}function R0(t){return t.map(O0).sort((e,l)=>e.scorel.score?-1:e.index-l.index)}function Sc(t,e){let l,n;const[i]=e.split("?"),o=vl(i),u=o[0]==="",a=R0(t);for(let f=0,c=a.length;f({...p,params:h,uri:$});if(p.default){n=d(e);continue}const v=vl(p.fullPath),g=Math.max(o.length,v.length);let A=0;for(;A{c===".."?f.pop():c!=="."&&f.push(c)}),Gs(`/${f.join("/")}`,n)}function $a(t,e){const{pathname:l,hash:n="",search:i="",state:o}=t,u=vl(e,!0),a=vl(l,!0);for(;u.length;)u[0]!==a[0]&&Tc(mn,`Invalid state: All locations must begin with the basepath "${e}", found "${l}"`),u.shift(),a.shift();return{pathname:Ni(...a),hash:n,search:i,state:o}}const Na=t=>t.length===1?"":t,wo=t=>{const e=t.indexOf("?"),l=t.indexOf("#"),n=e!==-1,i=l!==-1,o=i?Na(ki(t,l)):"",u=i?ki(t,0,l):t,a=n?Na(ki(u,e)):"";return{pathname:(n?ki(u,0,e):u)||"/",search:a,hash:o}},F0=t=>{const{pathname:e,search:l,hash:n}=t;return e+l+n};function q0(t,e,l){return Ni(l,L0(t,e))}function B0(t,e){const l=bo(y0(t)),n=vl(l,!0),i=vl(e,!0).slice(0,n.length),o=$c({fullPath:l},Ni(...i));return o&&o.uri}const Vs="POP",U0="PUSH",j0="REPLACE";function Ks(t){return{...t.location,pathname:encodeURI(decodeURI(t.location.pathname)),state:t.history.state,_key:t.history.state&&t.history.state._key||"initial"}}function H0(t){let e=[],l=Ks(t),n=Vs;const i=(o=e)=>o.forEach(u=>u({location:l,action:n}));return{get location(){return l},listen(o){e.push(o);const u=()=>{l=Ks(t),n=Vs,i([o])};i([o]);const a=pc(t,"popstate",u);return()=>{a(),e=e.filter(f=>f!==o)}},navigate(o,u){const{state:a={},replace:f=!1}=u||{};if(n=f?j0:U0,cc(o))u&&ws(Cc,"Navigation options (state or replace) are not supported, when passing a number as the first argument to navigate. They are ignored."),n=Vs,t.history.go(o);else{const c={...a,_key:v0()};try{t.history[f?"replaceState":"pushState"](c,"",o)}catch{t.location[f?"replace":"assign"](o)}}l=Ks(t),i()}}}function Ys(t,e){return{...wo(e),state:t}}function W0(t="/"){let e=0,l=[Ys(null,t)];return{get entries(){return l},get location(){return l[e]},addEventListener(){},removeEventListener(){},history:{get state(){return l[e].state},pushState(n,i,o){e++,l=l.slice(0,e),l.push(Ys(n,o))},replaceState(n,i,o){l[e]=Ys(n,o)},go(n){const i=e+n;i<0||i>l.length-1||(e=i)}}}}const z0=!!(!Wl&&window.document&&window.document.createElement),G0=!Wl&&window.location.origin==="null",Nc=H0(z0&&!G0?window:W0()),{navigate:si}=Nc;let Sl=null,Ec=!0;function V0(t,e){const l=document.querySelectorAll("[data-svnav-router]");for(let n=0;nSl.level||t.level===Sl.level&&V0(t.routerId,Sl.routerId))&&(Sl=t)}function Y0(){Sl=null}function Q0(){Ec=!1}function Ea(t){if(!t)return!1;const e="tabindex";try{if(!t.hasAttribute(e)){t.setAttribute(e,"-1");let l;l=pc(t,"blur",()=>{t.removeAttribute(e),l()})}return t.focus(),document.activeElement===t}catch{return!1}}function X0(t,e){return Number(t.dataset.svnavRouteEnd)===e}function Z0(t){return/^H[1-6]$/i.test(t.tagName)}function Aa(t,e=document){return e.querySelector(t)}function J0(t){let l=Aa(`[data-svnav-route-start="${t}"]`).nextElementSibling;for(;!X0(l,t);){if(Z0(l))return l;const n=Aa("h1,h2,h3,h4,h5,h6",l);if(n)return n;l=l.nextElementSibling}return null}function x0(t){Promise.resolve(ri(t.focusElement)).then(e=>{const l=e||J0(t.id);l||ws(mn,`Could not find an element to focus. You should always render a header for accessibility reasons, or set a custom focus element via the "useFocus" hook. If you don't want this Route or Router to manage focus, pass "primary={false}" to it.`,t,Ts),!Ea(l)&&Ea(document.documentElement)})}const e1=(t,e,l)=>(n,i)=>c0().then(()=>{if(!Sl||Ec){Q0();return}if(n&&x0(Sl.route),t.announcements&&i){const{path:o,fullPath:u,meta:a,params:f,uri:c}=Sl.route,p=t.createAnnouncement({path:o,fullPath:u,meta:a,params:f,uri:c},ri(l));Promise.resolve(p).then(_=>{e.set(_)})}Y0()}),t1="position:fixed;top:-1px;left:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";function l1(t){let e,l,n=[{role:"status"},{"aria-atomic":"true"},{"aria-live":"polite"},{"data-svnav-announcer":""},_c(t[6],t1)],i={};for(let o=0;o`Navigated to ${x.uri}`,announcements:!0,...v},$=p,M=bo(p),P=Hl(xs),F=Hl(ui),E=!P,I=i1(),D=d&&!(F&&!F.manageFocus),L=it("");_l(t,L,x=>l(0,a=x));const ie=F?F.disableInlineStyles:g,H=it([]);_l(t,H,x=>l(20,u=x));const K=it(null);_l(t,K,x=>l(18,i=x));let G=!1;const Y=E?0:F.level+1,z=E?it((()=>$a(Wl?wo(_):h.location,M))()):P;_l(t,z,x=>l(17,n=x));const Z=it(n);_l(t,Z,x=>l(19,o=x));const V=e1(A,L,z),j=x=>W=>W.filter(U=>U.id!==x);function ee(x){if(Wl){if(G)return;const W=$c(x,n.pathname);if(W)return G=!0,W}else H.update(W=>{const U=j(x.id)(W);return U.push(x),U})}function ue(x){H.update(j(x))}return!E&&p!==Pa&&ws(mn,'Only top-level Routers can have a "basepath" prop. It is ignored.',{basepath:p}),E&&(sc(()=>h.listen(W=>{const U=$a(W.location,M);Z.set(n),z.set(U)})),Mi(xs,z)),Mi(ui,{activeRoute:K,registerRoute:ee,unregisterRoute:ue,manageFocus:D,level:Y,id:I,history:E?h:F.history,basepath:E?M:F.basepath,disableInlineStyles:ie}),t.$$set=x=>{"basepath"in x&&l(11,p=x.basepath),"url"in x&&l(12,_=x.url),"history"in x&&l(13,h=x.history),"primary"in x&&l(14,d=x.primary),"a11y"in x&&l(15,v=x.a11y),"disableInlineStyles"in x&&l(16,g=x.disableInlineStyles),"$$scope"in x&&l(21,c=x.$$scope)},t.$$.update=()=>{if(t.$$.dirty[0]&2048&&p!==$&&ws(mn,'You cannot change the "basepath" prop. It is ignored.'),t.$$.dirty[0]&1179648){const x=Sc(u,n.pathname);K.set(x)}if(t.$$.dirty[0]&655360&&E){const x=!!n.hash,W=!x&&D,U=!x||n.pathname!==o.pathname;V(W,U)}t.$$.dirty[0]&262144&&D&&i&&i.primary&&K0({level:Y,routerId:I,route:i})},[a,A,E,I,D,L,ie,H,K,z,Z,p,_,h,d,v,g,n,i,o,u,c,f]}class o1 extends De{constructor(e){super(),Pe(this,e,s1,n1,$e,{basepath:11,url:12,history:13,primary:14,a11y:15,disableInlineStyles:16},null,[-1,-1])}}const Ac=o1;function Ei(t,e,l=ui,n=mn){Hl(l)||Tc(t,o=>`You cannot use ${o} outside of a ${ko(n)}.`,e)}const r1=t=>{const{subscribe:e}=Hl(t);return{subscribe:e}};function Pc(){return Ei(kc),r1(xs)}function Dc(){const{history:t}=Hl(ui);return t}function Ic(){const t=Hl(vc);return t?h0(t,e=>e.base):it("/")}function Oc(){Ei(yc);const t=Ic(),{basepath:e}=Hl(ui);return n=>q0(n,ri(t),e)}function a1(){Ei(wc);const t=Oc(),{navigate:e}=Dc();return(n,i)=>{const o=cc(n)?n:t(n);return e(o,i)}}const u1=t=>({params:t&16,location:t&8}),Da=t=>({params:Wl?ri(t[10]):t[4],location:t[3],navigate:t[11]});function Ia(t){let e,l;return e=new Ac({props:{primary:t[1],$$slots:{default:[m1]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.primary=n[1]),i&528409&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function f1(t){let e;const l=t[18].default,n=po(l,t,t[19],Da);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&524312)&&vo(n,l,i,i[19],e?_o(l,i[19],o,u1):ho(i[19]),Da)},i(i){e||(O(n,i),e=!0)},o(i){B(n,i),e=!1},d(i){n&&n.d(i)}}}function c1(t){let e,l,n;const i=[{location:t[3]},{navigate:t[11]},Wl?ri(t[10]):t[4],t[12]];var o=t[0];function u(a){let f={};for(let c=0;c{oe(p,1)}),Oe()}o?(e=ya(o,u()),re(e.$$.fragment),O(e.$$.fragment,1),se(e,l.parentNode,l)):e=null}else o&&e.$set(c)},i(a){n||(e&&O(e.$$.fragment,a),n=!0)},o(a){e&&B(e.$$.fragment,a),n=!1},d(a){a&&y(l),e&&oe(e,a)}}}function m1(t){let e,l,n,i;const o=[c1,f1],u=[];function a(f,c){return f[0]!==null?0:1}return e=a(t),l=u[e]=o[e](t),{c(){l.c(),n=Ve()},m(f,c){u[e].m(f,c),C(f,n,c),i=!0},p(f,c){let p=e;e=a(f),e===p?u[e].p(f,c):(Ie(),B(u[p],1,1,()=>{u[p]=null}),Oe(),l=u[e],l?l.p(f,c):(l=u[e]=o[e](f),l.c()),O(l,1),l.m(n.parentNode,n))},i(f){i||(O(l),i=!0)},o(f){B(l),i=!1},d(f){u[e].d(f),f&&y(n)}}}function p1(t){let e,l,n,i,o,u=[Js(t[7]),{"data-svnav-route-start":t[5]}],a={};for(let _=0;_{f=null}),Oe())},i(_){o||(O(f),o=!0)},o(_){B(f),o=!1},d(_){_&&y(e),_&&y(l),f&&f.d(_),_&&y(n),_&&y(i)}}}const _1=mc();function d1(t,e,l){let n;const i=["path","component","meta","primary"];let o=gs(e,i),u,a,f,c,{$$slots:p={},$$scope:_}=e,{path:h=""}=e,{component:d=null}=e,{meta:v={}}=e,{primary:g=!0}=e;Ei(Ts,e);const A=_1(),{registerRoute:$,unregisterRoute:M,activeRoute:P,disableInlineStyles:F}=Hl(ui);_l(t,P,G=>l(16,u=G));const E=Ic();_l(t,E,G=>l(17,f=G));const I=Pc();_l(t,I,G=>l(3,a=G));const D=it(null);let L;const ie=it(),H=it({});_l(t,H,G=>l(4,c=G)),Mi(vc,ie),Mi(b0,H),Mi(g0,D);const K=a1();return Wl||u0(()=>M(A)),t.$$set=G=>{l(24,e=sl(sl({},e),bs(G))),l(12,o=gs(e,i)),"path"in G&&l(13,h=G.path),"component"in G&&l(0,d=G.component),"meta"in G&&l(14,v=G.meta),"primary"in G&&l(1,g=G.primary),"$$scope"in G&&l(19,_=G.$$scope)},t.$$.update=()=>{if(t.$$.dirty&155658){const G=h==="",Y=Ni(f,h),Q={id:A,path:h,meta:v,default:G,fullPath:G?"":Y,base:G?f:B0(Y,a.pathname),primary:g,focusElement:D};ie.set(Q),l(15,L=$(Q))}if(t.$$.dirty&98304&&l(2,n=!!(L||u&&u.id===A)),t.$$.dirty&98308&&n){const{params:G}=L||u;H.set(G)}},e=bs(e),[d,g,n,a,c,A,P,F,E,I,H,K,o,h,v,L,u,f,p,_]}class v1 extends De{constructor(e){super(),Pe(this,e,d1,p1,$e,{path:13,component:0,meta:14,primary:1})}}const Tl=v1;function h1(t){let e,l,n,i;const o=t[13].default,u=po(o,t,t[12],null);let a=[{href:t[0]},t[2],t[1]],f={};for(let c=0;cl(11,_=D));const P=f0(),F=Oc(),{navigate:E}=Dc();function I(D){P("click",D),d0(D)&&(D.preventDefault(),E(n,{state:A,replace:u||g}))}return t.$$set=D=>{l(19,e=sl(sl({},e),bs(D))),l(18,p=gs(e,c)),"to"in D&&l(5,v=D.to),"replace"in D&&l(6,g=D.replace),"state"in D&&l(7,A=D.state),"getProps"in D&&l(8,$=D.getProps),"$$scope"in D&&l(12,d=D.$$scope)},t.$$.update=()=>{t.$$.dirty&2080&&l(0,n=F(v,_)),t.$$.dirty&2049&&l(10,i=eo(_.pathname,n)),t.$$.dirty&2049&&l(9,o=n===_.pathname),t.$$.dirty&2049&&(u=wo(n)===F0(_)),t.$$.dirty&512&&l(2,a=o?{"aria-current":"page"}:{}),l(1,f=(()=>{if(fc($)){const D=$({location:_,href:n,isPartiallyCurrent:i,isCurrent:o});return{...p,...D}}return p})())},e=bs(e),[n,f,a,M,I,v,g,A,$,o,i,_,d,h]}class g1 extends De{constructor(e){super(),Pe(this,e,b1,h1,$e,{to:5,replace:6,state:7,getProps:8})}}const ol=g1;let to=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function jl(t){return t===1?"green":t===2?"yellow":t===3?"red":"gray"}function k1(t){return t>218&&t<242?"#32d900":t>212&&t<248?"#b1d900":t>208&&t<252?"#ffb800":"#d90000"}function Rc(t){return t>90?"#d90000":t>85?"#e32100":t>80?"#ffb800":t>75?"#dcd800":"#32d900"}function w1(t){return t>75?"#32d900":t>50?"#77d900":t>25?"#94d900":"#dcd800"}function ys(t){switch(t){case 1:return"Aidon";case 2:return"Kaifa";case 3:return"Kamstrup";case 8:return"Iskra";case 9:return"Landis+Gyr";case 10:return"Sagemcom";default:return"Unknown"}}function Fe(t){for(t=t.toString();t.length<2;)t="0"+t;return t}function ve(t,e){switch(e){case 5:switch(t){case"esp8266":return"Pow-K (GPIO12)";case"esp32s2":return"Pow-K+"}case 7:switch(t){case"esp8266":return"Pow-U (GPIO12)";case"esp32s2":return"Pow-U+"}case 6:return"Pow-P1";case 51:return"Wemos S2 mini";case 50:return"Generic ESP32-S2";case 201:return"Wemos LOLIN D32";case 202:return"Adafruit HUZZAH32";case 203:return"DevKitC";case 241:return"LilyGO T-ETH-POE";case 242:return"M5 PoESP32";case 243:return"WT32-ETH01";case 200:return"Generic ESP32";case 2:return"HAN Reader 2.0 by Max Spencer";case 0:return"Custom hardware by Roar Fredriksen";case 1:return"Kamstrup module by Egil Opsahl";case 8:return"µHAN mosquito by dbeinder";case 3:return"Pow-K (UART0)";case 4:return"Pow-U (UART0)";case 101:return"Wemos D1 mini";case 100:return"Generic ESP8266";case 70:return"Generic ESP32-C3";case 71:return"ESP32-C3-DevKitM-1"}}function Oa(t){switch(t){case-1:return"Parse error";case-2:return"Incomplete data received";case-3:return"Payload boundry flag missing";case-4:return"Header checksum error";case-5:return"Footer checksum error";case-9:return"Unknown data received, check meter config";case-41:return"Frame length not equal";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid";case 90:return"No HAN data received for at least 30s";case 91:return"Serial break";case 92:return"Serial buffer full";case 93:return"Serial FIFO overflow";case 94:return"Serial frame error";case 95:return"Serial parity error";case 96:return"RX error";case 98:return"Exception in code, debugging necessary";case 99:return"Autodetection failed"}return t<0?"Unspecified error "+t:""}function Ra(t){switch(t){case-3:return"Connection failed";case-4:return"Network timeout";case-10:return"Connection denied";case-11:return"Failed to subscribe";case-13:return"Connection lost"}return t<0?"Unspecified error "+t:""}function La(t){switch(t){case 400:return"Unrecognized data in request";case 401:case 403:return"Unauthorized, check API key";case 404:return"Price unavailable, not found";case 425:return"Server says its too early";case 429:return"Exceeded API rate limit";case 500:return"Internal server error";case-1:return"Connection error";case-2:return"Incomplete data received";case-3:return"Invalid data, tag missing";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid"}return t<0?"Unspecified error "+t:""}function oi(t){switch(t){case 2:case 4:case 7:return!0}return!1}function Qe(t,e){return t==1||t==2&&e}function Ut(t){return"https://github.com/UtilitechAS/amsreader-firmware/wiki/"+t}function be(t,e){return isNaN(t)?"-":(isNaN(e)&&(e=t<10?1:0),t.toFixed(e))}function dl(t,e){return t.setTime(t.getTime()+e*36e5),t}function Fa(t){if(t.chip=="esp8266")switch(t.boot_reason){case 0:return"Normal";case 1:return"WDT reset";case 2:return"Exception reset";case 3:return"Soft WDT reset";case 4:return"Software restart";case 5:return"Deep sleep";case 6:return"External reset";default:return"Unknown (8266)"}else switch(t.boot_reason){case 1:return"Vbat power on reset";case 3:return"Software reset";case 4:return"WDT reset";case 5:return"Deep sleep";case 6:return"SLC reset";case 7:return"Timer Group0 WDT reset";case 8:return"Timer Group1 WDT reset";case 9:return"RTC WDT reset";case 10:return"Instrusion test reset CPU";case 11:return"Time Group reset CPU";case 12:return"Software reset CPU";case 13:return"RTC WTD reset CPU";case 14:return"PRO CPU";case 15:return"Brownout";case 16:return"RTC reset";default:return"Unknown"}}function qa(t){return t=="EOE"?"ENTSO-E":t=="HKS"?"hvakosterstrommen.no":t=="EDS"?"Energy Data Service":t=="MIX"?"Mixed sources":"Unknown ("+t+")"}async function $l(t,e={}){const{timeout:l=8e3}=e,n=new AbortController,i=setTimeout(()=>n.abort(),l),o=await fetch(t,{...e,signal:n.signal});return clearTimeout(i),o}let pl={version:"",chip:"",mac:null,apmac:null,vndcfg:null,usrcfg:null,fwconsent:null,booting:!1,upgrading:!1,ui:{},security:0,boot_reason:0,upgrade:{x:-1,e:0,f:null,t:null},trying:null};const Yt=it(pl);async function yo(){pl=await(await $l("/sysinfo.json?t="+Math.floor(Date.now()/1e3))).json(),Yt.set(pl)}let ds=0,Ba=-127,Ua=null,y1={};const Lc=dc(y1,t=>{let e;async function l(){$l("/data.json").then(n=>n.json()).then(n=>{t(n),Ba!=n.t&&(Ba=n.t,setTimeout(jc,2e3)),Ua==null&&n.pe&&n.p!=null&&(Ua=n.p,qc()),pl.upgrading?window.location.reload():(!pl||!pl.chip||pl.booting||ds>1&&!oi(pl.board))&&(yo(),an&&clearTimeout(an),an=setTimeout(Mo,2e3),un&&clearTimeout(un),un=setTimeout(To,3e3));let i=5e3;if(oi(pl.board)&&n.v>2.5){let o=3.3-Math.min(3.3,n.v);o>0&&(i=Math.max(o,.1)*10*5e3)}i>5e3&&console.log("Scheduling next data fetch in "+i+"ms"),e&&clearTimeout(e),e=setTimeout(l,i),ds=0}).catch(n=>{ds++,ds>3?(t({em:3,hm:0,wm:0,mm:0}),e=setTimeout(l,15e3)):e=setTimeout(l,oi(pl.board)?1e4:5e3)})}return l(),function(){clearTimeout(e)}});let lo={},wi;const Co=it(lo);async function Fc(){let t=!1;Co.update(e=>{for(var l=0;l<36;l++){if(e[Fe(l)]==null){t=l<12;break}e[Fe(l)]=e[Fe(l+1)]}return e}),t?qc():wi=setTimeout(Fc,(60-new Date().getMinutes())*6e4)}async function qc(){wi&&(clearTimeout(wi),wi=0),lo=await(await $l("/energyprice.json")).json(),Co.set(lo),wi=setTimeout(Fc,(60-new Date().getMinutes())*6e4)}let no={},an;async function Mo(){an&&(clearTimeout(an),an=0),no=await(await $l("/dayplot.json")).json(),Bc.set(no),an=setTimeout(Mo,(60-new Date().getMinutes())*6e4+20)}const Bc=it(no,t=>(Mo(),function(){}));let io={},un;async function To(){un&&(clearTimeout(un),un=0),io=await(await $l("/monthplot.json")).json(),Uc.set(io),un=setTimeout(To,(24-new Date().getHours())*36e5+40)}const Uc=it(io,t=>(To(),function(){}));let so={};async function jc(){so=await(await $l("/temperature.json")).json(),Hc.set(so)}const Hc=it(so,t=>(jc(),function(){}));let oo={},vs;async function Wc(){vs&&(clearTimeout(vs),vs=0),oo=await(await $l("/tariff.json")).json(),zc.set(oo),vs=setTimeout(Wc,(60-new Date().getMinutes())*6e4+30)}const zc=it(oo,t=>function(){});let ro=[];const So=it(ro);async function C1(){ro=await(await $l("https://api.github.com/repos/UtilitechAS/amsreader-firmware/releases")).json(),So.set(ro)}let ao={};async function M1(){ao=await(await $l("/realtime.json")).json(),Gc.set(ao)}const Gc=it(ao,t=>(M1(),function(){}));function Cs(t){return"WARNING: "+t+" must be connected to an external power supply during firmware upgrade. Failure to do so may cause power-down during upload resulting in non-functioning unit."}async function Vc(t){await(await fetch("/upgrade?expected_version="+t,{method:"POST"})).json()}function Kc(t,e){if(/^v\d{1,2}\.\d{1,2}\.\d{1,2}$/.test(t)){let l=t.substring(1).split("."),n=parseInt(l[0]),i=parseInt(l[1]),o=parseInt(l[2]),u=[...e];u.reverse();let a,f,c;for(let p=0;po&&(a=_):g==i+1&&(f=_);else if(v==n+1)if(c){let $=c.tag_name.substring(1).split(".");parseInt($[0]);let M=parseInt($[1]);parseInt($[2]),g==M&&(c=_)}else c=_}return f||c||a||!1}else return e[0]}const T1="/github.svg";function ja(t){let e,l;function n(u,a){return u[1]>1?D1:u[1]>0?P1:u[2]>1?A1:u[2]>0?E1:u[3]>1?N1:u[3]>0?$1:S1}let i=n(t),o=i(t);return{c(){e=S(`Up - `),o.c(),l=Ve()},m(u,a){C(u,e,a),o.m(u,a),C(u,l,a)},p(u,a){i===(i=n(u))&&o?o.p(u,a):(o.d(1),o=i(u),o&&(o.c(),o.m(l.parentNode,l)))},d(u){u&&y(e),o.d(u),u&&y(l)}}}function S1(t){let e,l;return{c(){e=S(t[0]),l=S(" seconds")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&1&&X(e,n[0])},d(n){n&&y(e),n&&y(l)}}}function $1(t){let e,l;return{c(){e=S(t[3]),l=S(" minute")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&8&&X(e,n[3])},d(n){n&&y(e),n&&y(l)}}}function N1(t){let e,l;return{c(){e=S(t[3]),l=S(" minutes")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&8&&X(e,n[3])},d(n){n&&y(e),n&&y(l)}}}function E1(t){let e,l;return{c(){e=S(t[2]),l=S(" hour")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&4&&X(e,n[2])},d(n){n&&y(e),n&&y(l)}}}function A1(t){let e,l;return{c(){e=S(t[2]),l=S(" hours")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&4&&X(e,n[2])},d(n){n&&y(e),n&&y(l)}}}function P1(t){let e,l;return{c(){e=S(t[1]),l=S(" day")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&2&&X(e,n[1])},d(n){n&&y(e),n&&y(l)}}}function D1(t){let e,l;return{c(){e=S(t[1]),l=S(" days")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&2&&X(e,n[1])},d(n){n&&y(e),n&&y(l)}}}function I1(t){let e,l=t[0]&&ja(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),C(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=ja(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:_e,o:_e,d(n){l&&l.d(n),n&&y(e)}}}function O1(t,e,l){let{epoch:n}=e,i=0,o=0,u=0;return t.$$set=a=>{"epoch"in a&&l(0,n=a.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,u=Math.floor(n/60)))},[n,i,o,u]}class R1 extends De{constructor(e){super(),Pe(this,e,O1,I1,$e,{epoch:0})}}function L1(t){let e,l,n;return{c(){e=m("span"),l=S(t[2]),r(e,"title",t[1]),r(e,"class",n="bd-"+t[0])},m(i,o){C(i,e,o),s(e,l)},p(i,[o]){o&4&&X(l,i[2]),o&2&&r(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&r(e,"class",n)},i:_e,o:_e,d(i){i&&y(e)}}}function F1(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=u=>{"color"in u&&l(0,n=u.color),"title"in u&&l(1,i=u.title),"text"in u&&l(2,o=u.text)},[n,i,o]}class fn extends De{constructor(e){super(),Pe(this,e,F1,L1,$e,{color:0,title:1,text:2})}}function q1(t){let e,l=`${Fe(t[0].getDate())}.${Fe(t[0].getMonth()+1)}.${t[0].getFullYear()} ${Fe(t[0].getHours())}:${Fe(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=S(l),r(e,"class",t[1])},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Fe(i[0].getDate())}.${Fe(i[0].getMonth()+1)}.${i[0].getFullYear()} ${Fe(i[0].getHours())}:${Fe(i[0].getMinutes())}`)&&X(n,l),o&2&&r(e,"class",i[1])},d(i){i&&y(e)}}}function B1(t){let e=`${Fe(t[0].getDate())}. ${to[t[0].getMonth()]} ${Fe(t[0].getHours())}:${Fe(t[0].getMinutes())}`,l;return{c(){l=S(e)},m(n,i){C(n,l,i)},p(n,i){i&1&&e!==(e=`${Fe(n[0].getDate())}. ${to[n[0].getMonth()]} ${Fe(n[0].getHours())}:${Fe(n[0].getMinutes())}`)&&X(l,e)},d(n){n&&y(l)}}}function U1(t){let e;function l(o,u){return o[2]?B1:q1}let n=l(t),i=n(t);return{c(){i.c(),e=Ve()},m(o,u){i.m(o,u),C(o,e,u)},p(o,[u]){n===(n=l(o))&&i?i.p(o,u):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},i:_e,o:_e,d(o){i.d(o),o&&y(e)}}}function j1(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e,{offset:o}=e,u;return t.$$set=a=>{"timestamp"in a&&l(0,n=a.timestamp),"fullTimeColor"in a&&l(1,i=a.fullTimeColor),"offset"in a&&l(3,o=a.offset)},t.$$.update=()=>{t.$$.dirty&9&&(l(2,u=Math.abs(new Date().getTime()-n.getTime())<3e5),isNaN(o)||dl(n,o-(24+n.getHours()-n.getUTCHours())%24))},[n,i,u,o]}class Yc extends De{constructor(e){super(),Pe(this,e,j1,U1,$e,{timestamp:0,fullTimeColor:1,offset:3})}}function H1(t){let e,l,n;return{c(){e=Se("svg"),l=Se("path"),n=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),r(n,"stroke-linecap","round"),r(n,"stroke-linejoin","round"),r(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(i,o){C(i,e,o),s(e,l),s(e,n)},p:_e,i:_e,o:_e,d(i){i&&y(e)}}}class W1 extends De{constructor(e){super(),Pe(this,e,null,H1,$e,{})}}function z1(t){let e,l;return{c(){e=Se("svg"),l=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){C(n,e,i),s(e,l)},p:_e,i:_e,o:_e,d(n){n&&y(e)}}}class G1 extends De{constructor(e){super(),Pe(this,e,null,z1,$e,{})}}function V1(t){let e,l;return{c(){e=Se("svg"),l=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){C(n,e,i),s(e,l)},p:_e,i:_e,o:_e,d(n){n&&y(e)}}}class Bt extends De{constructor(e){super(),Pe(this,e,null,V1,$e,{})}}function K1(t){let e,l;return{c(){e=Se("svg"),l=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){C(n,e,i),s(e,l)},p:_e,i:_e,o:_e,d(n){n&&y(e)}}}class Qc extends De{constructor(e){super(),Pe(this,e,null,K1,$e,{})}}function Y1(t){let e,l,n=t[1].version+"",i;return{c(){e=S("AMS reader "),l=m("span"),i=S(n)},m(o,u){C(o,e,u),C(o,l,u),s(l,i)},p(o,u){u&2&&n!==(n=o[1].version+"")&&X(i,n)},d(o){o&&y(e),o&&y(l)}}}function Ha(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=S(l),i=S("°C"),r(e,"class","flex-none my-auto")},m(o,u){C(o,e,u),s(e,n),s(e,i)},p(o,u){u&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&X(n,l)},d(o){o&&y(e)}}}function Wa(t){let e,l="HAN: "+Oa(t[0].he),n;return{c(){e=m("div"),n=S(l),r(e,"class","bd-red")},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Oa(i[0].he))&&X(n,l)},d(i){i&&y(e)}}}function za(t){let e,l="MQTT: "+Ra(t[0].me),n;return{c(){e=m("div"),n=S(l),r(e,"class","bd-red")},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+Ra(i[0].me))&&X(n,l)},d(i){i&&y(e)}}}function Ga(t){let e,l="PriceAPI: "+La(t[0].ee),n;return{c(){e=m("div"),n=S(l),r(e,"class","bd-red")},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="PriceAPI: "+La(i[0].ee))&&X(n,l)},d(i){i&&y(e)}}}function Va(t){let e,l,n,i,o,u;return l=new ol({props:{to:"/configuration",$$slots:{default:[Q1]},$$scope:{ctx:t}}}),o=new ol({props:{to:"/status",$$slots:{default:[X1]},$$scope:{ctx:t}}}),{c(){e=m("div"),re(l.$$.fragment),n=b(),i=m("div"),re(o.$$.fragment),r(e,"class","flex-none px-1 mt-1"),r(e,"title","Configuration"),r(i,"class","flex-none px-1 mt-1"),r(i,"title","Device information")},m(a,f){C(a,e,f),se(l,e,null),C(a,n,f),C(a,i,f),se(o,i,null),u=!0},i(a){u||(O(l.$$.fragment,a),O(o.$$.fragment,a),u=!0)},o(a){B(l.$$.fragment,a),B(o.$$.fragment,a),u=!1},d(a){a&&y(e),oe(l),a&&y(n),a&&y(i),oe(o)}}}function Q1(t){let e,l;return e=new W1({}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function X1(t){let e,l;return e=new G1({}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function Ka(t){let e,l,n,i,o;const u=[J1,Z1],a=[];function f(c,p){return c[1].security==0||c[0].a?0:1}return l=f(t),n=a[l]=u[l](t),{c(){e=m("div"),n.c(),r(e,"class","flex-none mr-3 text-yellow-500"),r(e,"title",i="New version: "+t[2].tag_name)},m(c,p){C(c,e,p),a[l].m(e,null),o=!0},p(c,p){let _=l;l=f(c),l===_?a[l].p(c,p):(Ie(),B(a[_],1,1,()=>{a[_]=null}),Oe(),n=a[l],n?n.p(c,p):(n=a[l]=u[l](c),n.c()),O(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+c[2].tag_name))&&r(e,"title",i)},i(c){o||(O(n),o=!0)},o(c){B(n),o=!1},d(c){c&&y(e),a[l].d()}}}function Z1(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=S("New version: "),i=S(n)},m(o,u){C(o,e,u),s(e,l),s(e,i)},p(o,u){u&4&&n!==(n=o[2].tag_name+"")&&X(i,n)},i:_e,o:_e,d(o){o&&y(e)}}}function J1(t){let e,l,n,i=t[2].tag_name+"",o,u,a,f,c,p;return a=new Qc({}),{c(){e=m("button"),l=m("span"),n=S("New version: "),o=S(i),u=b(),re(a.$$.fragment),r(l,"class","mt-1"),r(e,"class","flex")},m(_,h){C(_,e,h),s(e,l),s(l,n),s(l,o),s(e,u),se(a,e,null),f=!0,c||(p=le(e,"click",t[3]),c=!0)},p(_,h){(!f||h&4)&&i!==(i=_[2].tag_name+"")&&X(o,i)},i(_){f||(O(a.$$.fragment,_),f=!0)},o(_){B(a.$$.fragment,_),f=!1},d(_){_&&y(e),oe(a),c=!1,p()}}}function x1(t){let e,l,n,i,o,u,a,f,c,p,_,h,d=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue,x,W,U,ke,He,Be,We;i=new ol({props:{to:"/",$$slots:{default:[Y1]},$$scope:{ctx:t}}}),f=new R1({props:{epoch:t[0].u}});let Ne=t[0].t>-50&&Ha(t);M=new fn({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:jl(t[1].booting?2:t[0].em)}}),F=new fn({props:{title:"HAN",text:"HAN",color:jl(t[1].booting?9:t[0].hm)}}),I=new fn({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:jl(t[1].booting?9:t[0].wm)}}),L=new fn({props:{title:"MQTT",text:"MQTT",color:jl(t[1].booting?9:t[0].mm)}});let ge=(t[0].he<0||t[0].he>0)&&Wa(t),Re=t[0].me<0&&za(t),Me=(t[0].ee>0||t[0].ee<0)&&Ga(t);ue=new Yc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),offset:t[1].clock_offset,fullTimeColor:"text-red-500"}});let T=t[1].vndcfg&&t[1].usrcfg&&Va(t);He=new Bt({});let k=t[1].fwconsent===1&&t[2]&&Ka(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),re(i.$$.fragment),o=b(),u=m("div"),a=m("div"),re(f.$$.fragment),c=b(),Ne&&Ne.c(),p=b(),_=m("div"),h=S("Free mem: "),v=S(d),g=S("kb"),A=b(),$=m("div"),re(M.$$.fragment),P=b(),re(F.$$.fragment),E=b(),re(I.$$.fragment),D=b(),re(L.$$.fragment),ie=b(),ge&&ge.c(),H=b(),Re&&Re.c(),K=b(),Me&&Me.c(),G=b(),Y=m("div"),Q=m("div"),z=m("a"),Z=m("img"),j=b(),ee=m("div"),re(ue.$$.fragment),x=b(),T&&T.c(),W=b(),U=m("div"),ke=m("a"),re(He.$$.fragment),Be=b(),k&&k.c(),r(n,"class","flex text-lg text-gray-100 p-2"),r(a,"class","flex-none my-auto"),r(_,"class","flex-none my-auto"),r(u,"class","flex-none my-auto p-2 flex space-x-4"),r($,"class","flex-auto flex-wrap my-auto justify-center p-2"),r(Z,"class","gh-logo"),Xs(Z.src,V=T1)||r(Z,"src",V),r(Z,"alt","GitHub repo"),r(z,"class","float-right"),r(z,"href","https://github.com/UtilitechAS/amsreader-firmware"),r(z,"target","_blank"),r(z,"rel","noreferrer"),r(z,"aria-label","GitHub"),r(Q,"class","flex-none"),r(ee,"class","flex-none my-auto px-2"),r(ke,"href",Ut("")),r(ke,"target","_blank"),r(ke,"rel","noreferrer"),r(U,"class","flex-none px-1 mt-1"),r(U,"title","Documentation"),r(Y,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),r(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),r(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(w,N){C(w,e,N),s(e,l),s(l,n),se(i,n,null),s(l,o),s(l,u),s(u,a),se(f,a,null),s(u,c),Ne&&Ne.m(u,null),s(u,p),s(u,_),s(_,h),s(_,v),s(_,g),s(l,A),s(l,$),se(M,$,null),s($,P),se(F,$,null),s($,E),se(I,$,null),s($,D),se(L,$,null),s(l,ie),ge&&ge.m(l,null),s(l,H),Re&&Re.m(l,null),s(l,K),Me&&Me.m(l,null),s(l,G),s(l,Y),s(Y,Q),s(Q,z),s(z,Z),s(Y,j),s(Y,ee),se(ue,ee,null),s(Y,x),T&&T.m(Y,null),s(Y,W),s(Y,U),s(U,ke),se(He,ke,null),s(Y,Be),k&&k.m(Y,null),We=!0},p(w,[N]){const R={};N&18&&(R.$$scope={dirty:N,ctx:w}),i.$set(R);const J={};N&1&&(J.epoch=w[0].u),f.$set(J),w[0].t>-50?Ne?Ne.p(w,N):(Ne=Ha(w),Ne.c(),Ne.m(u,p)):Ne&&(Ne.d(1),Ne=null),(!We||N&1)&&d!==(d=(w[0].m?(w[0].m/1e3).toFixed(1):"-")+"")&&X(v,d);const te={};N&3&&(te.text=w[1].booting?"Booting":w[0].v>2?w[0].v.toFixed(2)+"V":"ESP"),N&3&&(te.color=jl(w[1].booting?2:w[0].em)),M.$set(te);const fe={};N&3&&(fe.color=jl(w[1].booting?9:w[0].hm)),F.$set(fe);const de={};N&1&&(de.text=w[0].r?w[0].r.toFixed(0)+"dBm":"WiFi"),N&3&&(de.color=jl(w[1].booting?9:w[0].wm)),I.$set(de);const we={};N&3&&(we.color=jl(w[1].booting?9:w[0].mm)),L.$set(we),w[0].he<0||w[0].he>0?ge?ge.p(w,N):(ge=Wa(w),ge.c(),ge.m(l,H)):ge&&(ge.d(1),ge=null),w[0].me<0?Re?Re.p(w,N):(Re=za(w),Re.c(),Re.m(l,K)):Re&&(Re.d(1),Re=null),w[0].ee>0||w[0].ee<0?Me?Me.p(w,N):(Me=Ga(w),Me.c(),Me.m(l,G)):Me&&(Me.d(1),Me=null);const Ee={};N&1&&(Ee.timestamp=w[0].c?new Date(w[0].c*1e3):new Date(0)),N&2&&(Ee.offset=w[1].clock_offset),ue.$set(Ee),w[1].vndcfg&&w[1].usrcfg?T?N&2&&O(T,1):(T=Va(w),T.c(),O(T,1),T.m(Y,W)):T&&(Ie(),B(T,1,1,()=>{T=null}),Oe()),w[1].fwconsent===1&&w[2]?k?(k.p(w,N),N&6&&O(k,1)):(k=Ka(w),k.c(),O(k,1),k.m(Y,null)):k&&(Ie(),B(k,1,1,()=>{k=null}),Oe())},i(w){We||(O(i.$$.fragment,w),O(f.$$.fragment,w),O(M.$$.fragment,w),O(F.$$.fragment,w),O(I.$$.fragment,w),O(L.$$.fragment,w),O(ue.$$.fragment,w),O(T),O(He.$$.fragment,w),O(k),We=!0)},o(w){B(i.$$.fragment,w),B(f.$$.fragment,w),B(M.$$.fragment,w),B(F.$$.fragment,w),B(I.$$.fragment,w),B(L.$$.fragment,w),B(ue.$$.fragment,w),B(T),B(He.$$.fragment,w),B(k),We=!1},d(w){w&&y(e),oe(i),oe(f),Ne&&Ne.d(),oe(M),oe(F),oe(I),oe(L),ge&&ge.d(),Re&&Re.d(),Me&&Me.d(),oe(ue),T&&T.d(),oe(He),k&&k.d()}}}function em(t,e,l){let{data:n={}}=e,i={},o={};function u(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!oi(i.board)||confirm(Cs(ve(i.chip,i.board))))&&(Yt.update(a=>(a.upgrading=!0,a)),Vc(o.tag_name))}return Yt.subscribe(a=>{l(1,i=a),a.fwconsent===1&&C1()}),So.subscribe(a=>{l(2,o=Kc(i.version,a))}),t.$$set=a=>{"data"in a&&l(0,n=a.data)},[n,i,o,u]}class tm extends De{constructor(e){super(),Pe(this,e,em,x1,$e,{data:0})}}function lm(t){let e,l,n,i;return{c(){e=Se("svg"),l=Se("path"),n=Se("path"),r(l,"d",Qs(150,150,115,210,510)),r(l,"stroke","rgba(128, 128, 128, 0.15)"),r(l,"fill","none"),r(l,"stroke-width","55"),r(n,"d",i=Qs(150,150,115,210,210+300*t[0]/100)),r(n,"stroke",t[1]),r(n,"fill","none"),r(n,"stroke-width","55"),r(e,"viewBox","0 0 300 300"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"height","100%")},m(o,u){C(o,e,u),s(e,l),s(e,n)},p(o,[u]){u&1&&i!==(i=Qs(150,150,115,210,210+300*o[0]/100))&&r(n,"d",i),u&2&&r(n,"stroke",o[1])},i:_e,o:_e,d(o){o&&y(e)}}}function Ya(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function Qs(t,e,l,n,i){var o=Ya(t,e,l,i),u=Ya(t,e,l,n),a=i-n<=180?"0":"1",f=["M",o.x,o.y,"A",l,l,0,a,0,u.x,u.y].join(" ");return f}function nm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class im extends De{constructor(e){super(),Pe(this,e,nm,lm,$e,{pct:0,color:1})}}function Qa(t){let e,l,n,i,o,u,a,f;return{c(){e=m("br"),l=b(),n=m("span"),i=S(t[3]),o=b(),u=m("span"),a=S(t[4]),f=S("/kWh"),r(n,"class","pl-sub"),r(u,"class","pl-snt")},m(c,p){C(c,e,p),C(c,l,p),C(c,n,p),s(n,i),C(c,o,p),C(c,u,p),s(u,a),s(u,f)},p(c,p){p&8&&X(i,c[3]),p&16&&X(a,c[4])},d(c){c&&y(e),c&&y(l),c&&y(n),c&&y(o),c&&y(u)}}}function sm(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A;l=new im({props:{pct:t[6],color:t[5](t[6])}});let $=t[3]&&Qa(t);return{c(){e=m("div"),re(l.$$.fragment),n=b(),i=m("span"),o=m("span"),u=S(t[2]),a=b(),f=m("br"),c=b(),p=m("span"),_=S(t[0]),h=b(),d=m("span"),v=S(t[1]),g=b(),$&&$.c(),r(o,"class","pl-lab"),r(p,"class","pl-val"),r(d,"class","pl-unt"),r(i,"class","pl-ov"),r(e,"class","pl-root")},m(M,P){C(M,e,P),se(l,e,null),s(e,n),s(e,i),s(i,o),s(o,u),s(i,a),s(i,f),s(i,c),s(i,p),s(p,_),s(i,h),s(i,d),s(d,v),s(i,g),$&&$.m(i,null),A=!0},p(M,[P]){const F={};P&64&&(F.pct=M[6]),P&96&&(F.color=M[5](M[6])),l.$set(F),(!A||P&4)&&X(u,M[2]),(!A||P&1)&&X(_,M[0]),(!A||P&2)&&X(v,M[1]),M[3]?$?$.p(M,P):($=Qa(M),$.c(),$.m(i,null)):$&&($.d(1),$=null)},i(M){A||(O(l.$$.fragment,M),A=!0)},o(M){B(l.$$.fragment,M),A=!1},d(M){M&&y(e),oe(l),$&&$.d()}}}function om(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:u}=e,{sub:a=""}=e,{subunit:f=""}=e,{colorFn:c}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,u=_.label),"sub"in _&&l(3,a=_.sub),"subunit"in _&&l(4,f=_.subunit),"colorFn"in _&&l(5,c=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,u,a,f,c,p,i]}class Xc extends De{constructor(e){super(),Pe(this,e,om,sm,$e,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function Xa(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Za(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Ja(t,e,l){const n=t.slice();return n[13]=e[l],n}function xa(t){let e,l,n,i,o,u=t[0].title&&eu(t),a=t[0].y.ticks,f=[];for(let d=0;d20||t[11]%2==0)&&iu(t);return{c(){e=Se("g"),n&&n.c(),r(e,"class","tick"),r(e,"transform",l="translate("+t[5](t[11])+","+t[4]+")")},m(i,o){C(i,e,o),n&&n.m(e,null)},p(i,o){i[3]>20||i[11]%2==0?n?n.p(i,o):(n=iu(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o&48&&l!==(l="translate("+i[5](i[11])+","+i[4]+")")&&r(e,"transform",l)},d(i){i&&y(e),n&&n.d()}}}function iu(t){let e,l=t[9].label+"",n,i;return{c(){e=Se("text"),n=S(l),r(e,"x",i=t[3]/2),r(e,"y","-4")},m(o,u){C(o,e,u),s(e,n)},p(o,u){u&1&&l!==(l=o[9].label+"")&&X(n,l),u&8&&i!==(i=o[3]/2)&&r(e,"x",i)},d(o){o&&y(e)}}}function su(t){let e=!isNaN(t[5](t[11])),l,n=e&&nu(t);return{c(){n&&n.c(),l=Ve()},m(i,o){n&&n.m(i,o),C(i,l,o)},p(i,o){o&32&&(e=!isNaN(i[5](i[11]))),e?n?n.p(i,o):(n=nu(i),n.c(),n.m(l.parentNode,l)):n&&(n.d(1),n=null)},d(i){n&&n.d(i),i&&y(l)}}}function ou(t){let e,l,n=t[9].value!==void 0&&ru(t),i=t[9].value2>1e-4&&fu(t);return{c(){e=Se("g"),n&&n.c(),l=Se("g"),i&&i.c()},m(o,u){C(o,e,u),n&&n.m(e,null),C(o,l,u),i&&i.m(l,null)},p(o,u){o[9].value!==void 0?n?n.p(o,u):(n=ru(o),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,u):(i=fu(o),i.c(),i.m(l,null)):i&&(i.d(1),i=null)},d(o){o&&y(e),n&&n.d(),o&&y(l),i&&i.d()}}}function ru(t){let e,l,n,i,o,u,a,f=t[3]>15&&au(t);return{c(){e=Se("rect"),f&&f.c(),a=Ve(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](t[9].value)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),r(e,"fill",u=t[9].color)},m(c,p){C(c,e,p),f&&f.m(c,p),C(c,a,p)},p(c,p){p&32&&l!==(l=c[5](c[11])+2)&&r(e,"x",l),p&65&&n!==(n=c[6](c[9].value))&&r(e,"y",n),p&8&&i!==(i=c[3]-4)&&r(e,"width",i),p&65&&o!==(o=c[6](c[0].y.min)-c[6](Math.min(c[0].y.min,0)+c[9].value))&&r(e,"height",o),p&1&&u!==(u=c[9].color)&&r(e,"fill",u),c[3]>15?f?f.p(c,p):(f=au(c),f.c(),f.m(a.parentNode,a)):f&&(f.d(1),f=null)},d(c){c&&y(e),f&&f.d(c),c&&y(a)}}}function au(t){let e,l=t[9].label+"",n,i,o,u,a,f,c=t[9].title&&uu(t);return{c(){e=Se("text"),n=S(l),c&&c.c(),f=Ve(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor",o=t[3]t[6](0)-t[7]?t[9].color:"white"),r(e,"transform",a="translate("+(t[5](t[11])+t[3]/2)+" "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10)+") rotate("+(t[3]p[6](0)-p[7]?p[9].color:"white")&&r(e,"fill",u),_&233&&a!==(a="translate("+(p[5](p[11])+p[3]/2)+" "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)+") rotate("+(p[3]15&&cu(t);return{c(){e=Se("rect"),f&&f.c(),a=Ve(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](0)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),r(e,"fill",u=t[9].color2?t[9].color2:t[9].color)},m(c,p){C(c,e,p),f&&f.m(c,p),C(c,a,p)},p(c,p){p&32&&l!==(l=c[5](c[11])+2)&&r(e,"x",l),p&64&&n!==(n=c[6](0))&&r(e,"y",n),p&8&&i!==(i=c[3]-4)&&r(e,"width",i),p&65&&o!==(o=c[6](c[0].y.min)-c[6](c[0].y.min+c[9].value2))&&r(e,"height",o),p&1&&u!==(u=c[9].color2?c[9].color2:c[9].color)&&r(e,"fill",u),c[3]>15?f?f.p(c,p):(f=cu(c),f.c(),f.m(a.parentNode,a)):f&&(f.d(1),f=null)},d(c){c&&y(e),f&&f.d(c),c&&y(a)}}}function cu(t){let e,l=t[9].label2+"",n,i,o,u,a,f=t[9].title2&&mu(t);return{c(){e=Se("text"),n=S(l),f&&f.c(),a=Ve(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor","middle"),r(e,"fill",o=t[6](-t[9].value2)t[8].call(e))},m(i,o){C(i,e,o),n&&n.m(e,null),l=ic(e,t[8].bind(e))},p(i,[o]){i[0].x.ticks&&i[0].points&&i[4]?n?n.p(i,o):(n=xa(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null)},i:_e,o:_e,d(i){i&&y(e),n&&n.d(),l()}}}let cn=30;function am(t,e,l){let{config:n}=e,i,o,u,a,f,c,p;function _(){i=this.clientWidth,o=this.clientHeight,l(1,i),l(2,o)}return t.$$set=h=>{"config"in h&&l(0,n=h.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,c=o-(n.title?20:0));let h=i-(n.padding.left+n.padding.right);l(3,u=h/n.points.length),l(7,p=un.y.max?g=n.padding.bottom:vc||g<0?0:g})}},[n,i,o,u,c,a,f,p,_]}class pn extends De{constructor(e){super(),Pe(this,e,am,rm,$e,{config:0})}}function um(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function fm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:u}=e,a={};function f(c){return{label:be(c)+"V",title:c.toFixed(1)+" V",value:isNaN(c)?0:c,color:k1(c||0)}}return t.$$set=c=>{"u1"in c&&l(1,n=c.u1),"u2"in c&&l(2,i=c.u2),"u3"in c&&l(3,o=c.u3),"ds"in c&&l(4,u=c.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let c=[],p=[];n>0&&(c.push({label:u===1?"L1-L2":"L1"}),p.push(f(n))),i>0&&(c.push({label:u===1?"L1-L3":"L2"}),p.push(f(i))),o>0&&(c.push({label:u===1?"L2-L3":"L3"}),p.push(f(o))),l(0,a={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:c},points:p})}},[a,n,i,o,u]}class cm extends De{constructor(e){super(),Pe(this,e,fm,um,$e,{u1:1,u2:2,u3:3,ds:4})}}function mm(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function pm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:u}=e,{i2:a}=e,{i3:f}=e,{max:c}=e,p={};function _(h){return{label:be(h)+"A",title:h.toFixed(1)+" A",value:isNaN(h)?0:h,color:Rc(h?h/c*100:0)}}return t.$$set=h=>{"u1"in h&&l(1,n=h.u1),"u2"in h&&l(2,i=h.u2),"u3"in h&&l(3,o=h.u3),"i1"in h&&l(4,u=h.i1),"i2"in h&&l(5,a=h.i2),"i3"in h&&l(6,f=h.i3),"max"in h&&l(7,c=h.max)},t.$$.update=()=>{if(t.$$.dirty&254){let h=[],d=[];n>0&&(h.push({label:"L1"}),d.push(_(u))),i>0&&(h.push({label:"L2"}),d.push(_(a))),o>0&&(h.push({label:"L3"}),d.push(_(f))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:c,ticks:[{value:0,label:"0%"},{value:c/4,label:"25%"},{value:c/2,label:"50%"},{value:c/4*3,label:"75%"},{value:c,label:"100%"}]},x:{ticks:h},points:d})}},[p,n,i,o,u,a,f,c]}class _m extends De{constructor(e){super(),Pe(this,e,pm,mm,$e,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function dm(t){let e,l,n,i,o,u,a,f=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",c,p,_,h,d,v,g=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",A,$,M,P,F,E,I,D=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",L,ie,H,K,G,Y,Q=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",z,Z;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=b(),i=m("div"),o=m("div"),o.textContent="Instant in",u=b(),a=m("div"),c=S(f),p=S(" VAr"),_=b(),h=m("div"),h.textContent="Instant out",d=b(),v=m("div"),A=S(g),$=S(" VAr"),M=b(),P=m("div"),F=m("div"),F.textContent="Total in",E=b(),I=m("div"),L=S(D),ie=S(" kVArh"),H=b(),K=m("div"),K.textContent="Total out",G=b(),Y=m("div"),z=S(Q),Z=S(" kVArh"),r(a,"class","text-right"),r(v,"class","text-right"),r(i,"class","grid grid-cols-2 mt-4"),r(I,"class","text-right"),r(Y,"class","text-right"),r(P,"class","grid grid-cols-2 mt-4"),r(e,"class","mx-2 text-sm")},m(V,j){C(V,e,j),s(e,l),s(e,n),s(e,i),s(i,o),s(i,u),s(i,a),s(a,c),s(a,p),s(i,_),s(i,h),s(i,d),s(i,v),s(v,A),s(v,$),s(e,M),s(e,P),s(P,F),s(P,E),s(P,I),s(I,L),s(I,ie),s(P,H),s(P,K),s(P,G),s(P,Y),s(Y,z),s(Y,Z)},p(V,[j]){j&1&&f!==(f=(typeof V[0]<"u"?V[0].toFixed(0):"-")+"")&&X(c,f),j&2&&g!==(g=(typeof V[1]<"u"?V[1].toFixed(0):"-")+"")&&X(A,g),j&4&&D!==(D=(typeof V[2]<"u"?V[2].toFixed(1):"-")+"")&&X(L,D),j&8&&Q!==(Q=(typeof V[3]<"u"?V[3].toFixed(1):"-")+"")&&X(z,Q)},i:_e,o:_e,d(V){V&&y(e)}}}function vm(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:u}=e;return t.$$set=a=>{"importInstant"in a&&l(0,n=a.importInstant),"exportInstant"in a&&l(1,i=a.exportInstant),"importTotal"in a&&l(2,o=a.importTotal),"exportTotal"in a&&l(3,u=a.exportTotal)},[n,i,o,u]}class hm extends De{constructor(e){super(),Pe(this,e,vm,dm,$e,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function _u(t){let e;function l(o,u){return o[3]?gm:bm}let n=l(t),i=n(t);return{c(){i.c(),e=Ve()},m(o,u){i.m(o,u),C(o,e,u)},p(o,u){n===(n=l(o))&&i?i.p(o,u):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&y(e)}}}function bm(t){let e,l,n,i,o,u,a=be(t[1].h.u,2)+"",f,c,p,_,h,d,v=be(t[1].d.u,1)+"",g,A,$,M,P,F,E=be(t[1].m.u)+"",I,D,L,ie,H,K,G=be(t[0].last_month.u)+"",Y,Q,z,Z,V=t[4]&&du(t);return{c(){e=m("strong"),e.textContent="Consumption",l=b(),n=m("div"),i=m("div"),i.textContent="Hour",o=b(),u=m("div"),f=S(a),c=S(" kWh"),p=b(),_=m("div"),_.textContent="Day",h=b(),d=m("div"),g=S(v),A=S(" kWh"),$=b(),M=m("div"),M.textContent="Month",P=b(),F=m("div"),I=S(E),D=S(" kWh"),L=b(),ie=m("div"),ie.textContent="Last month",H=b(),K=m("div"),Y=S(G),Q=S(" kWh"),z=b(),V&&V.c(),Z=Ve(),r(u,"class","text-right"),r(d,"class","text-right"),r(F,"class","text-right"),r(K,"class","text-right"),r(n,"class","grid grid-cols-2 mb-3")},m(j,ee){C(j,e,ee),C(j,l,ee),C(j,n,ee),s(n,i),s(n,o),s(n,u),s(u,f),s(u,c),s(n,p),s(n,_),s(n,h),s(n,d),s(d,g),s(d,A),s(n,$),s(n,M),s(n,P),s(n,F),s(F,I),s(F,D),s(n,L),s(n,ie),s(n,H),s(n,K),s(K,Y),s(K,Q),C(j,z,ee),V&&V.m(j,ee),C(j,Z,ee)},p(j,ee){ee&2&&a!==(a=be(j[1].h.u,2)+"")&&X(f,a),ee&2&&v!==(v=be(j[1].d.u,1)+"")&&X(g,v),ee&2&&E!==(E=be(j[1].m.u)+"")&&X(I,E),ee&1&&G!==(G=be(j[0].last_month.u)+"")&&X(Y,G),j[4]?V?V.p(j,ee):(V=du(j),V.c(),V.m(Z.parentNode,Z)):V&&(V.d(1),V=null)},d(j){j&&y(e),j&&y(l),j&&y(n),j&&y(z),V&&V.d(j),j&&y(Z)}}}function gm(t){let e,l,n,i,o,u,a=be(t[1].h.u,2)+"",f,c,p,_,h,d,v,g=be(t[1].d.u,1)+"",A,$,M,P,F,E,I,D=be(t[1].m.u)+"",L,ie,H,K,G,Y,Q,z=be(t[0].last_month.u)+"",Z,V,j,ee,ue,x,W,U,ke,He,Be,We=be(t[1].h.p,2)+"",Ne,ge,Re,Me,T,k,w,N=be(t[1].d.p,1)+"",R,J,te,fe,de,we,Ee,ae=be(t[1].m.p)+"",Ce,Je,Et,st,ht,lt,At,Ye=be(t[0].last_month.p)+"",Qt,Ht,bt,ze,xe=t[4]&&vu(t),Xe=t[4]&&hu(t),Ue=t[4]&&bu(t),qe=t[4]&&gu(t),et=t[4]&&ku(t),Ae=t[4]&&wu(t),Le=t[4]&&yu(t),pe=t[4]&&Cu(t);return{c(){e=m("strong"),e.textContent="Import",l=b(),n=m("div"),i=m("div"),i.textContent="Hour",o=b(),u=m("div"),f=S(a),c=S(" kWh"),p=b(),xe&&xe.c(),_=b(),h=m("div"),h.textContent="Day",d=b(),v=m("div"),A=S(g),$=S(" kWh"),M=b(),Xe&&Xe.c(),P=b(),F=m("div"),F.textContent="Month",E=b(),I=m("div"),L=S(D),ie=S(" kWh"),H=b(),Ue&&Ue.c(),K=b(),G=m("div"),G.textContent="Last mo.",Y=b(),Q=m("div"),Z=S(z),V=S(" kWh"),j=b(),qe&&qe.c(),ue=b(),x=m("strong"),x.textContent="Export",W=b(),U=m("div"),ke=m("div"),ke.textContent="Hour",He=b(),Be=m("div"),Ne=S(We),ge=S(" kWh"),Re=b(),et&&et.c(),Me=b(),T=m("div"),T.textContent="Day",k=b(),w=m("div"),R=S(N),J=S(" kWh"),te=b(),Ae&&Ae.c(),fe=b(),de=m("div"),de.textContent="Month",we=b(),Ee=m("div"),Ce=S(ae),Je=S(" kWh"),Et=b(),Le&&Le.c(),st=b(),ht=m("div"),ht.textContent="Last mo.",lt=b(),At=m("div"),Qt=S(Ye),Ht=S(" kWh"),bt=b(),pe&&pe.c(),r(u,"class","text-right"),r(v,"class","text-right"),r(I,"class","text-right"),r(Q,"class","text-right"),r(n,"class",ee="grid grid-cols-"+t[5]+" mb-3"),r(Be,"class","text-right"),r(w,"class","text-right"),r(Ee,"class","text-right"),r(At,"class","text-right"),r(U,"class",ze="grid grid-cols-"+t[5])},m(ce,ye){C(ce,e,ye),C(ce,l,ye),C(ce,n,ye),s(n,i),s(n,o),s(n,u),s(u,f),s(u,c),s(n,p),xe&&xe.m(n,null),s(n,_),s(n,h),s(n,d),s(n,v),s(v,A),s(v,$),s(n,M),Xe&&Xe.m(n,null),s(n,P),s(n,F),s(n,E),s(n,I),s(I,L),s(I,ie),s(n,H),Ue&&Ue.m(n,null),s(n,K),s(n,G),s(n,Y),s(n,Q),s(Q,Z),s(Q,V),s(n,j),qe&&qe.m(n,null),C(ce,ue,ye),C(ce,x,ye),C(ce,W,ye),C(ce,U,ye),s(U,ke),s(U,He),s(U,Be),s(Be,Ne),s(Be,ge),s(U,Re),et&&et.m(U,null),s(U,Me),s(U,T),s(U,k),s(U,w),s(w,R),s(w,J),s(U,te),Ae&&Ae.m(U,null),s(U,fe),s(U,de),s(U,we),s(U,Ee),s(Ee,Ce),s(Ee,Je),s(U,Et),Le&&Le.m(U,null),s(U,st),s(U,ht),s(U,lt),s(U,At),s(At,Qt),s(At,Ht),s(U,bt),pe&&pe.m(U,null)},p(ce,ye){ye&2&&a!==(a=be(ce[1].h.u,2)+"")&&X(f,a),ce[4]?xe?xe.p(ce,ye):(xe=vu(ce),xe.c(),xe.m(n,_)):xe&&(xe.d(1),xe=null),ye&2&&g!==(g=be(ce[1].d.u,1)+"")&&X(A,g),ce[4]?Xe?Xe.p(ce,ye):(Xe=hu(ce),Xe.c(),Xe.m(n,P)):Xe&&(Xe.d(1),Xe=null),ye&2&&D!==(D=be(ce[1].m.u)+"")&&X(L,D),ce[4]?Ue?Ue.p(ce,ye):(Ue=bu(ce),Ue.c(),Ue.m(n,K)):Ue&&(Ue.d(1),Ue=null),ye&1&&z!==(z=be(ce[0].last_month.u)+"")&&X(Z,z),ce[4]?qe?qe.p(ce,ye):(qe=gu(ce),qe.c(),qe.m(n,null)):qe&&(qe.d(1),qe=null),ye&32&&ee!==(ee="grid grid-cols-"+ce[5]+" mb-3")&&r(n,"class",ee),ye&2&&We!==(We=be(ce[1].h.p,2)+"")&&X(Ne,We),ce[4]?et?et.p(ce,ye):(et=ku(ce),et.c(),et.m(U,Me)):et&&(et.d(1),et=null),ye&2&&N!==(N=be(ce[1].d.p,1)+"")&&X(R,N),ce[4]?Ae?Ae.p(ce,ye):(Ae=wu(ce),Ae.c(),Ae.m(U,fe)):Ae&&(Ae.d(1),Ae=null),ye&2&&ae!==(ae=be(ce[1].m.p)+"")&&X(Ce,ae),ce[4]?Le?Le.p(ce,ye):(Le=yu(ce),Le.c(),Le.m(U,st)):Le&&(Le.d(1),Le=null),ye&1&&Ye!==(Ye=be(ce[0].last_month.p)+"")&&X(Qt,Ye),ce[4]?pe?pe.p(ce,ye):(pe=Cu(ce),pe.c(),pe.m(U,null)):pe&&(pe.d(1),pe=null),ye&32&&ze!==(ze="grid grid-cols-"+ce[5])&&r(U,"class",ze)},d(ce){ce&&y(e),ce&&y(l),ce&&y(n),xe&&xe.d(),Xe&&Xe.d(),Ue&&Ue.d(),qe&&qe.d(),ce&&y(ue),ce&&y(x),ce&&y(W),ce&&y(U),et&&et.d(),Ae&&Ae.d(),Le&&Le.d(),pe&&pe.d()}}}function du(t){let e,l,n,i,o,u,a=be(t[1].h.c,2)+"",f,c,p,_,h,d,v,g=be(t[1].d.c,1)+"",A,$,M,P,F,E,I,D=be(t[1].m.c)+"",L,ie,H,K,G,Y,Q,z=be(t[0].last_month.c)+"",Z,V,j;return{c(){e=m("strong"),e.textContent="Cost",l=b(),n=m("div"),i=m("div"),i.textContent="Hour",o=b(),u=m("div"),f=S(a),c=b(),p=S(t[2]),_=b(),h=m("div"),h.textContent="Day",d=b(),v=m("div"),A=S(g),$=b(),M=S(t[2]),P=b(),F=m("div"),F.textContent="Month",E=b(),I=m("div"),L=S(D),ie=b(),H=S(t[2]),K=b(),G=m("div"),G.textContent="Last month",Y=b(),Q=m("div"),Z=S(z),V=b(),j=S(t[2]),r(u,"class","text-right"),r(v,"class","text-right"),r(I,"class","text-right"),r(Q,"class","text-right"),r(n,"class","grid grid-cols-2")},m(ee,ue){C(ee,e,ue),C(ee,l,ue),C(ee,n,ue),s(n,i),s(n,o),s(n,u),s(u,f),s(u,c),s(u,p),s(n,_),s(n,h),s(n,d),s(n,v),s(v,A),s(v,$),s(v,M),s(n,P),s(n,F),s(n,E),s(n,I),s(I,L),s(I,ie),s(I,H),s(n,K),s(n,G),s(n,Y),s(n,Q),s(Q,Z),s(Q,V),s(Q,j)},p(ee,ue){ue&2&&a!==(a=be(ee[1].h.c,2)+"")&&X(f,a),ue&4&&X(p,ee[2]),ue&2&&g!==(g=be(ee[1].d.c,1)+"")&&X(A,g),ue&4&&X(M,ee[2]),ue&2&&D!==(D=be(ee[1].m.c)+"")&&X(L,D),ue&4&&X(H,ee[2]),ue&1&&z!==(z=be(ee[0].last_month.c)+"")&&X(Z,z),ue&4&&X(j,ee[2])},d(ee){ee&&y(e),ee&&y(l),ee&&y(n)}}}function vu(t){let e,l=be(t[1].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].h.c,2)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function hu(t){let e,l=be(t[1].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].d.c,1)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function bu(t){let e,l=be(t[1].m.c)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].m.c)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function gu(t){let e,l=be(t[0].last_month.c)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&1&&l!==(l=be(u[0].last_month.c)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function ku(t){let e,l=be(t[1].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].h.i,2)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function wu(t){let e,l=be(t[1].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].d.i,1)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function yu(t){let e,l=be(t[1].m.i)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].m.i)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function Cu(t){let e,l=be(t[0].last_month.i)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&1&&l!==(l=be(u[0].last_month.i)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function km(t){let e,l,n,i,o,u,a=t[1]&&_u(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=b(),i=m("br"),o=m("br"),u=b(),a&&a.c(),r(e,"class","mx-2 text-sm")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),s(e,u),a&&a.m(e,null)},p(f,[c]){f[1]?a?a.p(f,c):(a=_u(f),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},i:_e,o:_e,d(f){f&&y(e),a&&a.d()}}}function wm(t,e,l){let{sysinfo:n}=e,{data:i}=e,{currency:o}=e,{hasExport:u}=e,a=!1,f=3;return t.$$set=c=>{"sysinfo"in c&&l(0,n=c.sysinfo),"data"in c&&l(1,i=c.data),"currency"in c&&l(2,o=c.currency),"hasExport"in c&&l(3,u=c.hasExport)},t.$$.update=()=>{t.$$.dirty&18&&(l(4,a=i&&i.h&&(Math.abs(i.h.c)>.01||Math.abs(i.d.c)>.01||Math.abs(i.m.c)>.01||Math.abs(i.h.i)>.01||Math.abs(i.d.i)>.01||Math.abs(i.m.i)>.01)),l(5,f=a?3:2))},[n,i,o,u,a,f]}class ym extends De{constructor(e){super(),Pe(this,e,wm,km,$e,{sysinfo:0,data:1,currency:2,hasExport:3})}}function Cm(t){let e,l,n=qa(t[0].source)+"",i,o,u,a;return u=new pn({props:{config:t[1]}}),{c(){e=m("a"),l=S("Provided by: "),i=S(n),o=b(),re(u.$$.fragment),r(e,"href","https://transparency.entsoe.eu/"),r(e,"target","_blank"),r(e,"class","text-xs float-right z-40")},m(f,c){C(f,e,c),s(e,l),s(e,i),C(f,o,c),se(u,f,c),a=!0},p(f,[c]){(!a||c&1)&&n!==(n=qa(f[0].source)+"")&&X(i,n);const p={};c&2&&(p.config=f[1]),u.$set(p)},i(f){a||(O(u.$$.fragment,f),a=!0)},o(f){B(u.$$.fragment,f),a=!1},d(f){f&&y(e),f&&y(o),oe(u,f)}}}function Mm(t,e,l){let{json:n}=e,{sysinfo:i}=e,o={},u,a;return t.$$set=f=>{"json"in f&&l(0,n=f.json),"sysinfo"in f&&l(2,i=f.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&29){let f=n.currency,c=new Date().getUTCHours(),p=0,_=0,h=0,d=[],v=[],g=[];l(4,a=l(3,u=0));let A=new Date;for(dl(A,i.clock_offset-(24+A.getHours()-A.getUTCHours())%24),p=c;p<24&&(_=n[Fe(h++)],_!=null);p++)v.push({label:Fe(A.getHours())}),g.push(_*100),l(4,a=Math.min(a,_*100)),l(3,u=Math.max(u,_*100)),dl(A,1);for(p=0;p<24&&(_=n[Fe(h++)],_!=null);p++)v.push({label:Fe(A.getHours())}),g.push(_*100),l(4,a=Math.min(a,_*100)),l(3,u=Math.max(u,_*100)),dl(A,1);if(a>-100&&u<100){switch(f){case"NOK":case"SEK":case"DKK":f="øre";break;case"EUR":f="cent";break;default:f=f+"/100"}for(l(4,a*=100),l(3,u*=100),p=0;p=0?E.toFixed(I):"",title:E>=0?E.toFixed(2)+" "+f:"",value:_>=0?Math.abs(_):0,label2:E<0?E.toFixed(I):"",title2:E<0?E.toFixed(2)+" "+f:"",value2:_<0?Math.abs(_):0,color:"#7c3aed"})}let M=Math.max(u,Math.abs(a));if(a<0){l(4,a=Math.min(M/4*-1,a));let E=Math.ceil(Math.abs(a)/M*4),I=a/E;for(p=1;p{"json"in f&&l(1,n=f.json),"sysinfo"in f&&l(2,i=f.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let f=0,c=[],p=[],_=[];l(4,a=l(3,u=0));let h=dl(new Date,-24),d=new Date().getUTCHours();for(dl(h,i.clock_offset-(24+h.getHours()-h.getUTCHours())%24),f=d;f<24;f++){let $=n["i"+Fe(f)],M=n["e"+Fe(f)];$===void 0&&($=0),M===void 0&&(M=0),p.push({label:Fe(h.getHours())}),_.push({label:$.toFixed(1),title:$.toFixed(2)+" kWh",value:$*10,label2:M.toFixed(1),title2:M.toFixed(2)+" kWh",value2:M*10,color:"#7c3aed",color2:"#37829E"}),l(4,a=Math.max(a,M*10)),l(3,u=Math.max(u,$*10)),dl(h,1)}for(f=0;f{"json"in f&&l(1,n=f.json),"sysinfo"in f&&l(2,i=f.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let f=0,c=[],p=[],_=[];l(4,a=l(3,u=0));let h=new Date,d=new Date;for(dl(h,i.clock_offset-(24+h.getHours()-h.getUTCHours())%24),dl(d,i.clock_offset-(24+d.getHours()-d.getUTCHours())%24),d.setDate(0),f=h.getDate();f<=d.getDate();f++){let $=n["i"+Fe(f)],M=n["e"+Fe(f)];$===void 0&&($=0),M===void 0&&(M=0),p.push({label:Fe(f)}),_.push({label:$.toFixed($<10?1:0),title:$.toFixed(2)+" kWh",value:$,label2:M.toFixed(M<10?1:0),title2:M.toFixed(2)+" kWh",value2:M,color:"#7c3aed",color2:"#37829E"}),l(4,a=Math.max(a,M)),l(3,u=Math.max(u,$))}for(f=1;f{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,f=0,c=[],p=[],_=[];n.s&&n.s.forEach((v,g)=>{var A=v.n?v.n:v.a;f=v.v,f==-127&&(f=0),p.push({label:A.slice(-4)}),_.push({label:f.toFixed(1),value:f,color:"#7c3aed"}),l(3,u=Math.min(u,f)),l(2,o=Math.max(o,f))}),l(2,o=Math.ceil(o)),l(3,u=Math.floor(u));let h=o;u<0&&(h+=Math.abs(u));let d=h/4;for(a=0;a<5;a++)f=u+d*a,c.push({value:f,label:f.toFixed(1)});l(0,i={title:"Temperature sensors (°C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:u,max:o,ticks:c},x:{ticks:p},points:_})}},[i,n,o,u]}class Om extends De{constructor(e){super(),Pe(this,e,Im,Dm,$e,{json:1})}}function Rm(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}let Lm=0;function Fm(t,e,l){let n={},i=0,o;return zc.subscribe(u=>{l(2,o=u)}),Wc(),t.$$.update=()=>{if(t.$$.dirty&6){let u=0,a=[],f=[],c=[];if(a.push({value:0,label:0}),o&&o.p)for(u=0;u0?Fe(p.d)+"."+to[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(u=0;u=i)break;a.push({value:p,label:p})}a.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(a.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:Lm,max:i,ticks:a},x:{ticks:f},points:c})}},[n,i,o]}class qm extends De{constructor(e){super(),Pe(this,e,Fm,Rm,$e,{})}}function Mu(t,e,l){const n=t.slice();return n[18]=e[l],n[20]=l,n}function Tu(t,e,l){const n=t.slice();return n[21]=e[l],n}function Su(t){let e,l,n,i,o,u=t[7],a=[];for(let p=0;pt[14].call(e))},m(c,p){C(c,e,p),s(e,l),s(l,n),s(l,i),s(l,o),s(e,u),f&&f.m(e,null),a=ic(e,t[14].bind(e))},p(c,[p]){p&1024&&X(i,c[10]),c[7]?f?f.p(c,p):(f=Su(c),f.c(),f.m(e,null)):f&&(f.d(1),f=null)},i:_e,o:_e,d(c){c&&y(e),f&&f.d(),a()}}}let Um=12;function jm(t,e,l){let n;Gc.subscribe(E=>{l(11,n=E)});let i,o=0;function u(){n.data.unshift(0),l(11,n.data=n.data.slice(0,n.size),n),o+=10,i=setTimeout(u,1e4)}Lc.subscribe(E=>{o>0?n.data&&E.u-o>=10&&(i&&clearTimeout(i),n.data.unshift(E.i-E.e),l(11,n.data=n.data.slice(0,n.size),n),o+=10,i=setTimeout(u,1e4)):o=E.u});let a,f,c,p,_,h,d,v,g,A,$,M,P;function F(){c=this.clientWidth,p=this.clientHeight,l(0,c),l(1,p)}return t.$$.update=()=>{if(t.$$.dirty&14847&&(l(2,_=parseInt(p)-50),l(3,h=c-35),l(9,M=h/n.size),l(13,f=0),l(12,a=0),n.data)){for(let I in n.data){let D=n.data[I];l(12,a=Math.max(Math.ceil(D/1e3)*1e3,a)),l(13,f=Math.min(Math.ceil(D/1e3)*1e3,f))}l(10,P=a>2500?"kW":"W"),l(7,A=[]);for(let I=f;I2500?(I/1e3).toFixed(1):I});l(8,$=[]);for(let I=f;I0||t[0].e>0}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&2&&(u.sysinfo=i[1]),o&1&&(u.data=i[0].ea),o&1&&(u.currency=i[0].pc),o&1&&(u.hasExport=i[0].om>0||i[0].e>0),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function qu(t){let e,l,n;return l=new qm({}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt h-64")},m(i,o){C(i,e,o),se(l,e,null),n=!0},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Bu(t){let e,l,n;return l=new Hm({}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Uu(t){let e,l,n;return l=new Tm({props:{json:t[2],sysinfo:t[1]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&4&&(u.json=i[2]),o&2&&(u.sysinfo=i[1]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function ju(t){let e,l,n;return l=new Nm({props:{json:t[3],sysinfo:t[1]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&8&&(u.json=i[3]),o&2&&(u.sysinfo=i[1]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Hu(t){let e,l,n;return l=new Pm({props:{json:t[4],sysinfo:t[1]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&16&&(u.json=i[4]),o&2&&(u.sysinfo=i[1]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Wu(t){let e,l,n;return l=new Om({props:{json:t[5]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&32&&(u.json=i[5]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Wm(t){let e,l=Qe(t[1].ui.i,t[0].i),n,i=Qe(t[1].ui.e,t[0].om||t[0].e>0),o,u=Qe(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),a,f=Qe(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),c,p=Qe(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,h=Qe(t[1].ui.c,t[0].ea),d,v=Qe(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),g,A=Qe(t[1].ui.l),$,M=Qe(t[1].ui.p,t[0].pe&&!Number.isNaN(t[0].p)),P,F=Qe(t[1].ui.d,t[3]),E,I=Qe(t[1].ui.m,t[4]),D,L=Qe(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),ie,H=l&&Du(t),K=i&&Iu(t),G=u&&Ou(t),Y=f&&Ru(t),Q=p&&Lu(t),z=h&&Fu(t),Z=v&&qu(),V=A&&Bu(),j=M&&Uu(t),ee=F&&ju(t),ue=I&&Hu(t),x=L&&Wu(t);return{c(){e=m("div"),H&&H.c(),n=b(),K&&K.c(),o=b(),G&&G.c(),a=b(),Y&&Y.c(),c=b(),Q&&Q.c(),_=b(),z&&z.c(),d=b(),Z&&Z.c(),g=b(),V&&V.c(),$=b(),j&&j.c(),P=b(),ee&&ee.c(),E=b(),ue&&ue.c(),D=b(),x&&x.c(),r(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(W,U){C(W,e,U),H&&H.m(e,null),s(e,n),K&&K.m(e,null),s(e,o),G&&G.m(e,null),s(e,a),Y&&Y.m(e,null),s(e,c),Q&&Q.m(e,null),s(e,_),z&&z.m(e,null),s(e,d),Z&&Z.m(e,null),s(e,g),V&&V.m(e,null),s(e,$),j&&j.m(e,null),s(e,P),ee&&ee.m(e,null),s(e,E),ue&&ue.m(e,null),s(e,D),x&&x.m(e,null),ie=!0},p(W,[U]){U&3&&(l=Qe(W[1].ui.i,W[0].i)),l?H?(H.p(W,U),U&3&&O(H,1)):(H=Du(W),H.c(),O(H,1),H.m(e,n)):H&&(Ie(),B(H,1,1,()=>{H=null}),Oe()),U&3&&(i=Qe(W[1].ui.e,W[0].om||W[0].e>0)),i?K?(K.p(W,U),U&3&&O(K,1)):(K=Iu(W),K.c(),O(K,1),K.m(e,o)):K&&(Ie(),B(K,1,1,()=>{K=null}),Oe()),U&3&&(u=Qe(W[1].ui.v,W[0].u1>100||W[0].u2>100||W[0].u3>100)),u?G?(G.p(W,U),U&3&&O(G,1)):(G=Ou(W),G.c(),O(G,1),G.m(e,a)):G&&(Ie(),B(G,1,1,()=>{G=null}),Oe()),U&3&&(f=Qe(W[1].ui.a,W[0].i1>.01||W[0].i2>.01||W[0].i3>.01)),f?Y?(Y.p(W,U),U&3&&O(Y,1)):(Y=Ru(W),Y.c(),O(Y,1),Y.m(e,c)):Y&&(Ie(),B(Y,1,1,()=>{Y=null}),Oe()),U&3&&(p=Qe(W[1].ui.r,W[0].ri>0||W[0].re>0||W[0].ric>0||W[0].rec>0)),p?Q?(Q.p(W,U),U&3&&O(Q,1)):(Q=Lu(W),Q.c(),O(Q,1),Q.m(e,_)):Q&&(Ie(),B(Q,1,1,()=>{Q=null}),Oe()),U&3&&(h=Qe(W[1].ui.c,W[0].ea)),h?z?(z.p(W,U),U&3&&O(z,1)):(z=Fu(W),z.c(),O(z,1),z.m(e,d)):z&&(Ie(),B(z,1,1,()=>{z=null}),Oe()),U&3&&(v=Qe(W[1].ui.t,W[0].pr&&(W[0].pr.startsWith("10YNO")||W[0].pr=="10Y1001A1001A48H"))),v?Z?U&3&&O(Z,1):(Z=qu(),Z.c(),O(Z,1),Z.m(e,g)):Z&&(Ie(),B(Z,1,1,()=>{Z=null}),Oe()),U&2&&(A=Qe(W[1].ui.l)),A?V?U&2&&O(V,1):(V=Bu(),V.c(),O(V,1),V.m(e,$)):V&&(Ie(),B(V,1,1,()=>{V=null}),Oe()),U&3&&(M=Qe(W[1].ui.p,W[0].pe&&!Number.isNaN(W[0].p))),M?j?(j.p(W,U),U&3&&O(j,1)):(j=Uu(W),j.c(),O(j,1),j.m(e,P)):j&&(Ie(),B(j,1,1,()=>{j=null}),Oe()),U&10&&(F=Qe(W[1].ui.d,W[3])),F?ee?(ee.p(W,U),U&10&&O(ee,1)):(ee=ju(W),ee.c(),O(ee,1),ee.m(e,E)):ee&&(Ie(),B(ee,1,1,()=>{ee=null}),Oe()),U&18&&(I=Qe(W[1].ui.m,W[4])),I?ue?(ue.p(W,U),U&18&&O(ue,1)):(ue=Hu(W),ue.c(),O(ue,1),ue.m(e,D)):ue&&(Ie(),B(ue,1,1,()=>{ue=null}),Oe()),U&35&&(L=Qe(W[1].ui.s,W[0].t&&W[0].t!=-127&&W[5].c>1)),L?x?(x.p(W,U),U&35&&O(x,1)):(x=Wu(W),x.c(),O(x,1),x.m(e,null)):x&&(Ie(),B(x,1,1,()=>{x=null}),Oe())},i(W){ie||(O(H),O(K),O(G),O(Y),O(Q),O(z),O(Z),O(V),O(j),O(ee),O(ue),O(x),ie=!0)},o(W){B(H),B(K),B(G),B(Y),B(Q),B(z),B(Z),B(V),B(j),B(ee),B(ue),B(x),ie=!1},d(W){W&&y(e),H&&H.d(),K&&K.d(),G&&G.d(),Y&&Y.d(),Q&&Q.d(),z&&z.d(),Z&&Z.d(),V&&V.d(),j&&j.d(),ee&&ee.d(),ue&&ue.d(),x&&x.d()}}}function zm(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},u={},a={},f={};return Co.subscribe(c=>{l(2,o=c)}),Bc.subscribe(c=>{l(3,u=c)}),Uc.subscribe(c=>{l(4,a=c)}),Hc.subscribe(c=>{l(5,f=c)}),t.$$set=c=>{"data"in c&&l(0,n=c.data),"sysinfo"in c&&l(1,i=c.sysinfo)},[n,i,o,u,a,f]}class Gm extends De{constructor(e){super(),Pe(this,e,zm,Wm,$e,{data:0,sysinfo:1})}}let uo={};const yi=it(uo);async function Vm(){uo=await(await fetch("/configuration.json")).json(),yi.set(uo)}function zu(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function Km(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=3,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Ym(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=20,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Gu(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Vu(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=b(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){C(i,e,o),C(i,l,o),C(i,n,o)},d(i){i&&y(e),i&&y(l),i&&y(n)}}}function Ku(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Yu(t){let e,l,n;return{c(){e=m("option"),l=S("GPIO"),n=S(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){C(i,e,o),s(e,l),s(e,n)},d(i){i&&y(e)}}}function Qu(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&Yu(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),C(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=Yu(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&y(e)}}}function Qm(t){let e,l,n,i,o;function u(v,g){return v[0]=="esp32c3"?Ym:Km}let a=u(t),f=a(t),c=t[0]=="esp8266"&&Gu(),p=(t[0]=="esp32"||t[0]=="esp32solo")&&Vu(),_=t[0]=="esp32s2"&&Ku(),h={length:t[1]+1},d=[];for(let v=0;v{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{if(t.$$.dirty&1)switch(n){case"esp8266":l(1,i=16);break;case"esp32s2":l(1,i=44);break;case"esp32c3":l(1,i=19);break}},[n,i]}class fo extends De{constructor(e){super(),Pe(this,e,Xm,Qm,$e,{chip:0})}}function Xu(t){let e,l,n=t[1]&&Zu(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),r(l,"class","fixed inset-0 bg-gray-500 dark:bg-gray-900 bg-opacity-50 flex items-center justify-center"),r(e,"class","z-50"),r(e,"aria-modal","true")},m(i,o){C(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=Zu(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&y(e),n&&n.d()}}}function Zu(t){let e,l;return{c(){e=m("div"),l=S(t[1]),r(e,"class","bg-white dark:bg-gray-600 m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 dark:text-white w-96")},m(n,i){C(n,e,i),s(e,l)},p(n,i){i&2&&X(l,n[1])},d(n){n&&y(e)}}}function Zm(t){let e,l=t[0]&&Xu(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),C(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=Xu(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:_e,o:_e,d(n){l&&l.d(n),n&&y(e)}}}function Jm(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class jt extends De{constructor(e){super(),Pe(this,e,Jm,Zm,$e,{active:0,message:1})}}function Ju(t,e,l){const n=t.slice();return n[1]=e[l],n}function xu(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=S("Europe/"),i=S(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,u){C(o,e,u),s(e,l),s(e,i)},p:_e,d(o){o&&y(e)}}}function xm(t){let e,l,n,i=t[0],o=[];for(let u=0;u>1&1,N=0;N0;k--)N[k]=N[k]?N[k-1]^E.EXPONENT[L._modN(E.LOG[N[k]]+T)]:N[k-1];N[0]=E.EXPONENT[L._modN(E.LOG[N[0]]+T)]}for(T=0;T<=w;T++)N[T]=E.LOG[N[T]]},_checkBadness:function(){var T,k,w,N,R,J=0,te=this._badness,fe=this.buffer,de=this.width;for(R=0;Rde*de;)ae-=de*de,Ee++;for(J+=Ee*L.N4,N=0;N=te-2&&(T=te-2,R>9&&T--);var fe=T;if(R>9){for(J[fe+2]=0,J[fe+3]=0;fe--;)k=J[fe],J[fe+3]|=255&k<<4,J[fe+2]=k>>4;J[2]|=255&T<<4,J[1]=T>>4,J[0]=64|T>>12}else{for(J[fe+1]=0,J[fe+2]=0;fe--;)k=J[fe],J[fe+2]|=255&k<<4,J[fe+1]=k>>4;J[1]|=255&T<<4,J[0]=64|T>>4}for(fe=T+3-(R<10);fe=5&&(w+=L.N1+N[k]-5);for(k=3;kT||N[k-3]*3>=N[k]*4||N[k+3]*3>=N[k]*4)&&(w+=L.N3);return w},_finish:function(){this._stringBuffer=this.buffer.slice();var T,k,w=0,N=3e4;for(k=0;k<8&&(this._applyMask(k),T=this._checkBadness(),T>=1)N&1&&(R[J-1-k+J*8]=1,k<6?R[8+J*k]=1:R[8+J*(k+1)]=1);for(k=0;k<7;k++,N>>=1)N&1&&(R[8+J*(J-7+k)]=1,k?R[6-k+J*8]=1:R[7+J*8]=1)},_interleaveBlocks:function(){var T,k,w=this._dataBlock,N=this._ecc,R=this._eccBlock,J=0,te=this._calculateMaxLength(),fe=this._neccBlock1,de=this._neccBlock2,we=this._stringBuffer;for(T=0;T1)for(T=$.BLOCK[N],w=R-7;;){for(k=R-7;k>T-3&&(this._addAlignment(k,w),!(k6)for(T=D.BLOCK[J-7],k=17,w=0;w<6;w++)for(N=0;N<3;N++,k--)1&(k>11?J>>k-12:T>>k)?(R[5-w+te*(2-N+te-11)]=1,R[2-N+te-11+te*(5-w)]=1):(this._setMask(5-w,2-N+te-11),this._setMask(2-N+te-11,5-w))},_isMasked:function(T,k){var w=L._getMaskBit(T,k);return this._mask[w]===1},_pack:function(){var T,k,w,N=1,R=1,J=this.width,te=J-1,fe=J-1,de=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(k=0;kk&&(w=T,T=k,k=w),w=k,w+=k*k,w>>=1,w+=T,w},_modN:function(T){for(;T>=255;)T-=255,T=(T>>8)+(T&255);return T},N1:3,N2:3,N3:40,N4:10}),ie=L,H=d.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var T=this.element;T.width=T.height=this.qrious.size}}),K=H,G=_.extend(function(T,k,w,N){this.name=T,this.modifiable=!!k,this.defaultValue=w,this._valueTransformer=N},{transform:function(T){var k=this._valueTransformer;return typeof k=="function"?k(T,this):T}}),Y=G,Q=_.extend(null,{abs:function(T){return T!=null?Math.abs(T):null},hasOwn:function(T,k){return Object.prototype.hasOwnProperty.call(T,k)},noop:function(){},toUpperCase:function(T){return T!=null?T.toUpperCase():null}}),z=Q,Z=_.extend(function(T){this.options={},T.forEach(function(k){this.options[k.name]=k},this)},{exists:function(T){return this.options[T]!=null},get:function(T,k){return Z._get(this.options[T],k)},getAll:function(T){var k,w=this.options,N={};for(k in w)z.hasOwn(w,k)&&(N[k]=Z._get(w[k],T));return N},init:function(T,k,w){typeof w!="function"&&(w=z.noop);var N,R;for(N in this.options)z.hasOwn(this.options,N)&&(R=this.options[N],Z._set(R,R.defaultValue,k),Z._createAccessor(R,k,w));this._setAll(T,k,!0)},set:function(T,k,w){return this._set(T,k,w)},setAll:function(T,k){return this._setAll(T,k)},_set:function(T,k,w,N){var R=this.options[T];if(!R)throw new Error("Invalid option: "+T);if(!R.modifiable&&!N)throw new Error("Option cannot be modified: "+T);return Z._set(R,k,w)},_setAll:function(T,k,w){if(!T)return!1;var N,R=!1;for(N in T)z.hasOwn(T,N)&&this._set(N,T[N],k,w)&&(R=!0);return R}},{_createAccessor:function(T,k,w){var N={get:function(){return Z._get(T,k)}};T.modifiable&&(N.set=function(R){Z._set(T,R,k)&&w(R,T)}),Object.defineProperty(k,T.name,N)},_get:function(T,k){return k["_"+T.name]},_set:function(T,k,w){var N="_"+T.name,R=w[N],J=T.transform(k??T.defaultValue);return w[N]=J,J!==R}}),V=Z,j=_.extend(function(){this._services={}},{getService:function(T){var k=this._services[T];if(!k)throw new Error("Service is not being managed with name: "+T);return k},setService:function(T,k){if(this._services[T])throw new Error("Service is already managed with name: "+T);k&&(this._services[T]=k)}}),ee=j,ue=new V([new Y("background",!0,"white"),new Y("backgroundAlpha",!0,1,z.abs),new Y("element"),new Y("foreground",!0,"black"),new Y("foregroundAlpha",!0,1,z.abs),new Y("level",!0,"L",z.toUpperCase),new Y("mime",!0,"image/png"),new Y("padding",!0,null,z.abs),new Y("size",!0,100,z.abs),new Y("value",!0,"")]),x=new ee,W=_.extend(function(T){ue.init(T,this,this.update.bind(this));var k=ue.get("element",this),w=x.getService("element"),N=k&&w.isCanvas(k)?k:w.createCanvas(),R=k&&w.isImage(k)?k:w.createImage();this._canvasRenderer=new g(this,N,!0),this._imageRenderer=new K(this,R,R===k),this.update()},{get:function(){return ue.getAll(this)},set:function(T){ue.setAll(T,this)&&this.update()},toDataURL:function(T){return this.canvas.toDataURL(T||this.mime)},update:function(){var T=new ie({level:this.level,value:this.value});this._canvasRenderer.render(T),this._imageRenderer.render(T)}},{use:function(T){x.setService(T.getName(),T)}});Object.defineProperties(W.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var U=W,ke=U,He=_.extend({getName:function(){}}),Be=He,We=Be.extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(T){},isImage:function(T){}}),Ne=We,ge=Ne.extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(T){return T instanceof HTMLCanvasElement},isImage:function(T){return T instanceof HTMLImageElement}}),Re=ge;ke.use(new Re);var Me=ke;return Me})})(Jc);var op=Jc.exports;const rp=sp(op);function ap(t){let e,l;return{c(){e=m("img"),Xs(e.src,l=t[2])||r(e,"src",l),r(e,"alt",t[0]),r(e,"class",t[1])},m(n,i){C(n,e,i)},p(n,[i]){i&4&&!Xs(e.src,l=n[2])&&r(e,"src",l),i&1&&r(e,"alt",n[0]),i&2&&r(e,"class",n[1])},i:_e,o:_e,d(n){n&&y(e)}}}function up(t,e,l){const n=new rp;let{errorCorrection:i="L"}=e,{background:o="#fff"}=e,{color:u="#000"}=e,{size:a="200"}=e,{value:f=""}=e,{padding:c=0}=e,{className:p="qrcode"}=e,_="";function h(){n.set({background:o,foreground:u,level:i,padding:c,size:a,value:f}),l(2,_=n.toDataURL("image/jpeg"))}return sc(()=>{h()}),t.$$set=d=>{"errorCorrection"in d&&l(3,i=d.errorCorrection),"background"in d&&l(4,o=d.background),"color"in d&&l(5,u=d.color),"size"in d&&l(6,a=d.size),"value"in d&&l(0,f=d.value),"padding"in d&&l(7,c=d.padding),"className"in d&&l(1,p=d.className)},t.$$.update=()=>{t.$$.dirty&1&&f&&h()},[f,p,_,i,o,u,a,c]}class fp extends De{constructor(e){super(),Pe(this,e,up,ap,$e,{errorCorrection:3,background:4,color:5,size:6,value:0,padding:7,className:1})}}function ef(t,e,l){const n=t.slice();return n[103]=e[l],n[104]=e,n[105]=l,n}function tf(t,e,l){const n=t.slice();return n[106]=e[l],n[107]=e,n[108]=l,n}function cp(t,e,l){const n=t.slice();return n[109]=e[l],n}function mp(t,e,l){const n=t.slice();return n[112]=e[l],n}function pp(t){let e,l;return{c(){e=m("option"),l=S(t[112]),e.__value=t[112],e.value=e.__value},m(n,i){C(n,e,i),s(e,l)},p:_e,d(n){n&&y(e)}}}function lf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","pt"),r(l,"type","text"),r(l,"class","in-s"),r(l,"placeholder","ENTSO-E API key, optional, read docs")},m(o,u){C(o,e,u),C(o,l,u),ne(l,t[3].p.t),n||(i=le(l,"input",t[22]),n=!0)},p(o,u){u[0]&8&&l.value!==o[3].p.t&&ne(l,o[3].p.t)},d(o){o&&y(e),o&&y(l),n=!1,i()}}}function nf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d;return{c(){e=m("div"),l=S("Username"),n=m("br"),i=b(),o=m("input"),u=b(),a=m("div"),f=S("Password"),c=m("br"),p=b(),_=m("input"),r(o,"name","gu"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(_,"name","gp"),r(_,"type","password"),r(_,"class","in-s"),r(a,"class","my-1")},m(v,g){C(v,e,g),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].g.u),C(v,u,g),C(v,a,g),s(a,f),s(a,c),s(a,p),s(a,_),ne(_,t[3].g.p),h||(d=[le(o,"input",t[24]),le(_,"input",t[25])],h=!0)},p(v,g){g[0]&8&&o.value!==v[3].g.u&&ne(o,v[3].g.u),g[0]&8&&_.value!==v[3].g.p&&ne(_,v[3].g.p)},d(v){v&&y(e),v&&y(u),v&&y(a),h=!1,Ge(d)}}}function _p(t){let e,l=t[109]*100+"",n;return{c(){e=m("option"),n=S(l),e.__value=t[109]*100,e.value=e.__value},m(i,o){C(i,e,o),s(e,n)},p:_e,d(i){i&&y(e)}}}function sf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","mek"),r(l,"type","text"),r(l,"class","in-s")},m(o,u){C(o,e,u),C(o,l,u),ne(l,t[3].m.e.k),n||(i=le(l,"input",t[35]),n=!0)},p(o,u){u[0]&8&&l.value!==o[3].m.e.k&&ne(l,o[3].m.e.k)},d(o){o&&y(e),o&&y(l),n=!1,i()}}}function of(t){let e,l,n,i,o,u,a;return{c(){e=m("div"),l=S("Authentication key"),n=m("br"),i=b(),o=m("input"),r(o,"name","mea"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].m.e.a),u||(a=le(o,"input",t[36]),u=!0)},p(f,c){c[0]&8&&o.value!==f[3].m.e.a&&ne(o,f[3].m.e.a)},d(f){f&&y(e),u=!1,a()}}}function rf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H;return{c(){e=m("div"),l=m("div"),n=S("Watt"),i=m("br"),o=b(),u=m("input"),a=b(),f=m("div"),c=S("Volt"),p=m("br"),_=b(),h=m("input"),d=b(),v=m("div"),g=S("Amp"),A=m("br"),$=b(),M=m("input"),P=b(),F=m("div"),E=S("kWh"),I=m("br"),D=b(),L=m("input"),r(u,"name","mmw"),r(u,"type","number"),r(u,"min","0.00"),r(u,"max","1000"),r(u,"step","0.001"),r(u,"class","in-f tr w-full"),r(l,"class","w-1/4"),r(h,"name","mmv"),r(h,"type","number"),r(h,"min","0.00"),r(h,"max","1000"),r(h,"step","0.001"),r(h,"class","in-m tr w-full"),r(f,"class","w-1/4"),r(M,"name","mma"),r(M,"type","number"),r(M,"min","0.00"),r(M,"max","1000"),r(M,"step","0.001"),r(M,"class","in-m tr w-full"),r(v,"class","w-1/4"),r(L,"name","mmc"),r(L,"type","number"),r(L,"min","0.00"),r(L,"max","1000"),r(L,"step","0.001"),r(L,"class","in-l tr w-full"),r(F,"class","w-1/4"),r(e,"class","flex my-1")},m(K,G){C(K,e,G),s(e,l),s(l,n),s(l,i),s(l,o),s(l,u),ne(u,t[3].m.m.w),s(e,a),s(e,f),s(f,c),s(f,p),s(f,_),s(f,h),ne(h,t[3].m.m.v),s(e,d),s(e,v),s(v,g),s(v,A),s(v,$),s(v,M),ne(M,t[3].m.m.a),s(e,P),s(e,F),s(F,E),s(F,I),s(F,D),s(F,L),ne(L,t[3].m.m.c),ie||(H=[le(u,"input",t[38]),le(h,"input",t[39]),le(M,"input",t[40]),le(L,"input",t[41])],ie=!0)},p(K,G){G[0]&8&&he(u.value)!==K[3].m.m.w&&ne(u,K[3].m.m.w),G[0]&8&&he(h.value)!==K[3].m.m.v&&ne(h,K[3].m.m.v),G[0]&8&&he(M.value)!==K[3].m.m.a&&ne(M,K[3].m.m.a),G[0]&8&&he(L.value)!==K[3].m.m.c&&ne(L,K[3].m.m.c)},d(K){K&&y(e),ie=!1,Ge(H)}}}function af(t){let e;return{c(){e=m("option"),e.textContent="Ethernet",e.__value=3,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function uf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue,x,W;return{c(){e=m("div"),l=S("SSID"),n=m("br"),i=b(),o=m("input"),u=b(),a=m("div"),f=S("Password"),c=m("br"),p=b(),_=m("input"),h=b(),d=m("div"),v=m("div"),g=S("Power saving"),A=m("br"),$=b(),M=m("select"),P=m("option"),P.textContent="Default",F=m("option"),F.textContent="Off",E=m("option"),E.textContent="Minimum",I=m("option"),I.textContent="Maximum",D=b(),L=m("div"),ie=S("Power"),H=m("br"),K=b(),G=m("div"),Y=m("input"),Q=b(),z=m("span"),z.textContent="dBm",Z=b(),V=m("div"),j=m("label"),ee=m("input"),ue=S(" Allow 802.11b legacy rates"),r(o,"name","ws"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(_,"name","wp"),r(_,"type","password"),r(_,"class","in-s"),r(a,"class","my-1"),P.__value=255,P.value=P.__value,F.__value=0,F.value=F.__value,E.__value=1,E.value=E.__value,I.__value=2,I.value=I.__value,r(M,"name","wz"),r(M,"class","in-s"),t[3].w.z===void 0&&Ke(()=>t[45].call(M)),r(v,"class","w-1/2"),r(Y,"name","ww"),r(Y,"type","number"),r(Y,"min","0"),r(Y,"max","20.5"),r(Y,"step","0.5"),r(Y,"class","in-f tr w-full"),r(z,"class","in-post"),r(G,"class","flex"),r(L,"class","ml-2 w-1/2"),r(d,"class","my-1 flex"),r(ee,"type","checkbox"),r(ee,"name","wb"),ee.__value="true",ee.value=ee.__value,r(ee,"class","rounded mb-1"),r(V,"class","my-3")},m(U,ke){C(U,e,ke),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].w.s),C(U,u,ke),C(U,a,ke),s(a,f),s(a,c),s(a,p),s(a,_),ne(_,t[3].w.p),C(U,h,ke),C(U,d,ke),s(d,v),s(v,g),s(v,A),s(v,$),s(v,M),s(M,P),s(M,F),s(M,E),s(M,I),Te(M,t[3].w.z,!0),s(d,D),s(d,L),s(L,ie),s(L,H),s(L,K),s(L,G),s(G,Y),ne(Y,t[3].w.w),s(G,Q),s(G,z),C(U,Z,ke),C(U,V,ke),s(V,j),s(j,ee),ee.checked=t[3].w.b,s(j,ue),x||(W=[le(o,"input",t[43]),le(_,"input",t[44]),le(M,"change",t[45]),le(Y,"input",t[46]),le(ee,"change",t[47])],x=!0)},p(U,ke){ke[0]&8&&o.value!==U[3].w.s&&ne(o,U[3].w.s),ke[0]&8&&_.value!==U[3].w.p&&ne(_,U[3].w.p),ke[0]&8&&Te(M,U[3].w.z),ke[0]&8&&he(Y.value)!==U[3].w.w&&ne(Y,U[3].w.w),ke[0]&8&&(ee.checked=U[3].w.b)},d(U){U&&y(e),U&&y(u),U&&y(a),U&&y(h),U&&y(d),U&&y(Z),U&&y(V),x=!1,Ge(W)}}}function ff(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A;return{c(){e=m("div"),l=S("Gateway"),n=m("br"),i=b(),o=m("input"),u=b(),a=m("div"),f=S("DNS"),c=m("br"),p=b(),_=m("div"),h=m("input"),d=b(),v=m("input"),r(o,"name","ng"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(h,"name","nd1"),r(h,"type","text"),r(h,"class","in-f w-full"),r(v,"name","nd2"),r(v,"type","text"),r(v,"class","in-l w-full"),r(_,"class","flex"),r(a,"class","my-1")},m($,M){C($,e,M),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].n.g),C($,u,M),C($,a,M),s(a,f),s(a,c),s(a,p),s(a,_),s(_,h),ne(h,t[3].n.d1),s(_,d),s(_,v),ne(v,t[3].n.d2),g||(A=[le(o,"input",t[51]),le(h,"input",t[52]),le(v,"input",t[53])],g=!0)},p($,M){M[0]&8&&o.value!==$[3].n.g&&ne(o,$[3].n.g),M[0]&8&&h.value!==$[3].n.d1&&ne(h,$[3].n.d1),M[0]&8&&v.value!==$[3].n.d2&&ne(v,$[3].n.d2)},d($){$&&y(e),$&&y(u),$&&y(a),g=!1,Ge(A)}}}function cf(t){let e,l,n,i,o;return{c(){e=m("label"),l=m("input"),n=S(" SSL"),r(l,"type","checkbox"),r(l,"name","qs"),l.__value="true",l.value=l.__value,r(l,"class","rounded mb-1"),r(e,"class","float-right mr-3")},m(u,a){C(u,e,a),s(e,l),l.checked=t[3].q.s.e,s(e,n),i||(o=[le(l,"change",t[57]),le(l,"change",t[14])],i=!0)},p(u,a){a[0]&8&&(l.checked=u[3].q.s.e)},d(u){u&&y(e),i=!1,Ge(o)}}}function mf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d;const v=[vp,dp],g=[];function A(D,L){return D[3].q.s.c?0:1}n=A(t),i=g[n]=v[n](t);const $=[kp,gp],M=[];function P(D,L){return D[3].q.s.r?0:1}a=P(t),f=M[a]=$[a](t);const F=[Mp,Cp],E=[];function I(D,L){return D[3].q.s.k?0:1}return _=I(t),h=E[_]=F[_](t),{c(){e=m("div"),l=m("span"),i.c(),o=b(),u=m("span"),f.c(),c=b(),p=m("span"),h.c(),r(l,"class","flex pr-2"),r(u,"class","flex pr-2"),r(p,"class","flex pr-2"),r(e,"class","my-1 flex")},m(D,L){C(D,e,L),s(e,l),g[n].m(l,null),s(e,o),s(e,u),M[a].m(u,null),s(e,c),s(e,p),E[_].m(p,null),d=!0},p(D,L){let ie=n;n=A(D),n===ie?g[n].p(D,L):(Ie(),B(g[ie],1,1,()=>{g[ie]=null}),Oe(),i=g[n],i?i.p(D,L):(i=g[n]=v[n](D),i.c()),O(i,1),i.m(l,null));let H=a;a=P(D),a===H?M[a].p(D,L):(Ie(),B(M[H],1,1,()=>{M[H]=null}),Oe(),f=M[a],f?f.p(D,L):(f=M[a]=$[a](D),f.c()),O(f,1),f.m(u,null));let K=_;_=I(D),_===K?E[_].p(D,L):(Ie(),B(E[K],1,1,()=>{E[K]=null}),Oe(),h=E[_],h?h.p(D,L):(h=E[_]=F[_](D),h.c()),O(h,1),h.m(p,null))},i(D){d||(O(i),O(f),O(h),d=!0)},o(D){B(i),B(f),B(h),d=!1},d(D){D&&y(e),g[n].d(),M[a].d(),E[_].d()}}}function dp(t){let e,l;return e=new ol({props:{to:"/mqtt-ca",$$slots:{default:[hp]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i[3]&4194304&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function vp(t){let e,l,n,i,o,u,a,f;return l=new ol({props:{to:"/mqtt-ca",$$slots:{default:[bp]},$$scope:{ctx:t}}}),o=new $o({}),{c(){e=m("span"),re(l.$$.fragment),n=b(),i=m("span"),re(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(c,p){C(c,e,p),se(l,e,null),C(c,n,p),C(c,i,p),se(o,i,null),u=!0,a||(f=[le(i,"click",t[11]),le(i,"keypress",t[11])],a=!0)},p(c,p){const _={};p[3]&4194304&&(_.$$scope={dirty:p,ctx:c}),l.$set(_)},i(c){u||(O(l.$$.fragment,c),O(o.$$.fragment,c),u=!0)},o(c){B(l.$$.fragment,c),B(o.$$.fragment,c),u=!1},d(c){c&&y(e),oe(l),c&&y(n),c&&y(i),oe(o),a=!1,Ge(f)}}}function hp(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload CA",title:"Click here to upload CA"}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p:_e,i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function bp(t){let e;return{c(){e=S("CA OK")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function gp(t){let e,l;return e=new ol({props:{to:"/mqtt-cert",$$slots:{default:[wp]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i[3]&4194304&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function kp(t){let e,l,n,i,o,u,a,f;return l=new ol({props:{to:"/mqtt-cert",$$slots:{default:[yp]},$$scope:{ctx:t}}}),o=new $o({}),{c(){e=m("span"),re(l.$$.fragment),n=b(),i=m("span"),re(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(c,p){C(c,e,p),se(l,e,null),C(c,n,p),C(c,i,p),se(o,i,null),u=!0,a||(f=[le(i,"click",t[12]),le(i,"keypress",t[12])],a=!0)},p(c,p){const _={};p[3]&4194304&&(_.$$scope={dirty:p,ctx:c}),l.$set(_)},i(c){u||(O(l.$$.fragment,c),O(o.$$.fragment,c),u=!0)},o(c){B(l.$$.fragment,c),B(o.$$.fragment,c),u=!1},d(c){c&&y(e),oe(l),c&&y(n),c&&y(i),oe(o),a=!1,Ge(f)}}}function wp(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p:_e,i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function yp(t){let e;return{c(){e=S("Cert OK")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Cp(t){let e,l;return e=new ol({props:{to:"/mqtt-key",$$slots:{default:[Tp]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i[3]&4194304&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function Mp(t){let e,l,n,i,o,u,a,f;return l=new ol({props:{to:"/mqtt-key",$$slots:{default:[Sp]},$$scope:{ctx:t}}}),o=new $o({}),{c(){e=m("span"),re(l.$$.fragment),n=b(),i=m("span"),re(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(c,p){C(c,e,p),se(l,e,null),C(c,n,p),C(c,i,p),se(o,i,null),u=!0,a||(f=[le(i,"click",t[13]),le(i,"keypress",t[13])],a=!0)},p(c,p){const _={};p[3]&4194304&&(_.$$scope={dirty:p,ctx:c}),l.$set(_)},i(c){u||(O(l.$$.fragment,c),O(o.$$.fragment,c),u=!0)},o(c){B(l.$$.fragment,c),B(o.$$.fragment,c),u=!1},d(c){c&&y(e),oe(l),c&&y(n),c&&y(i),oe(o),a=!1,Ge(f)}}}function Tp(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p:_e,i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function Sp(t){let e;return{c(){e=S("Key OK")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function pf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z;return o=new Bt({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=b(),i=m("a"),re(o.$$.fragment),u=b(),a=m("input"),f=b(),c=m("div"),p=m("div"),_=S("Electricity IDX"),h=m("br"),d=b(),v=m("input"),g=b(),A=m("div"),$=S("Current IDX"),M=m("br"),P=b(),F=m("input"),E=b(),I=m("div"),D=S(`Voltage IDX: L1, L2 & L3 + `),o.c(),l=Ve()},m(u,a){C(u,e,a),o.m(u,a),C(u,l,a)},p(u,a){i===(i=n(u))&&o?o.p(u,a):(o.d(1),o=i(u),o&&(o.c(),o.m(l.parentNode,l)))},d(u){u&&y(e),o.d(u),u&&y(l)}}}function S1(t){let e,l;return{c(){e=S(t[0]),l=S(" seconds")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&1&&X(e,n[0])},d(n){n&&y(e),n&&y(l)}}}function $1(t){let e,l;return{c(){e=S(t[3]),l=S(" minute")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&8&&X(e,n[3])},d(n){n&&y(e),n&&y(l)}}}function N1(t){let e,l;return{c(){e=S(t[3]),l=S(" minutes")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&8&&X(e,n[3])},d(n){n&&y(e),n&&y(l)}}}function E1(t){let e,l;return{c(){e=S(t[2]),l=S(" hour")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&4&&X(e,n[2])},d(n){n&&y(e),n&&y(l)}}}function A1(t){let e,l;return{c(){e=S(t[2]),l=S(" hours")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&4&&X(e,n[2])},d(n){n&&y(e),n&&y(l)}}}function P1(t){let e,l;return{c(){e=S(t[1]),l=S(" day")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&2&&X(e,n[1])},d(n){n&&y(e),n&&y(l)}}}function D1(t){let e,l;return{c(){e=S(t[1]),l=S(" days")},m(n,i){C(n,e,i),C(n,l,i)},p(n,i){i&2&&X(e,n[1])},d(n){n&&y(e),n&&y(l)}}}function I1(t){let e,l=t[0]&&ja(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),C(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=ja(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:_e,o:_e,d(n){l&&l.d(n),n&&y(e)}}}function O1(t,e,l){let{epoch:n}=e,i=0,o=0,u=0;return t.$$set=a=>{"epoch"in a&&l(0,n=a.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,u=Math.floor(n/60)))},[n,i,o,u]}class R1 extends De{constructor(e){super(),Pe(this,e,O1,I1,$e,{epoch:0})}}function L1(t){let e,l,n;return{c(){e=m("span"),l=S(t[2]),r(e,"title",t[1]),r(e,"class",n="bd-"+t[0])},m(i,o){C(i,e,o),s(e,l)},p(i,[o]){o&4&&X(l,i[2]),o&2&&r(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&r(e,"class",n)},i:_e,o:_e,d(i){i&&y(e)}}}function F1(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=u=>{"color"in u&&l(0,n=u.color),"title"in u&&l(1,i=u.title),"text"in u&&l(2,o=u.text)},[n,i,o]}class fn extends De{constructor(e){super(),Pe(this,e,F1,L1,$e,{color:0,title:1,text:2})}}function q1(t){let e,l=`${Fe(t[0].getDate())}.${Fe(t[0].getMonth()+1)}.${t[0].getFullYear()} ${Fe(t[0].getHours())}:${Fe(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=S(l),r(e,"class",t[1])},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Fe(i[0].getDate())}.${Fe(i[0].getMonth()+1)}.${i[0].getFullYear()} ${Fe(i[0].getHours())}:${Fe(i[0].getMinutes())}`)&&X(n,l),o&2&&r(e,"class",i[1])},d(i){i&&y(e)}}}function B1(t){let e=`${Fe(t[0].getDate())}. ${to[t[0].getMonth()]} ${Fe(t[0].getHours())}:${Fe(t[0].getMinutes())}`,l;return{c(){l=S(e)},m(n,i){C(n,l,i)},p(n,i){i&1&&e!==(e=`${Fe(n[0].getDate())}. ${to[n[0].getMonth()]} ${Fe(n[0].getHours())}:${Fe(n[0].getMinutes())}`)&&X(l,e)},d(n){n&&y(l)}}}function U1(t){let e;function l(o,u){return o[2]?B1:q1}let n=l(t),i=n(t);return{c(){i.c(),e=Ve()},m(o,u){i.m(o,u),C(o,e,u)},p(o,[u]){n===(n=l(o))&&i?i.p(o,u):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},i:_e,o:_e,d(o){i.d(o),o&&y(e)}}}function j1(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e,{offset:o}=e,u;return t.$$set=a=>{"timestamp"in a&&l(0,n=a.timestamp),"fullTimeColor"in a&&l(1,i=a.fullTimeColor),"offset"in a&&l(3,o=a.offset)},t.$$.update=()=>{t.$$.dirty&9&&(l(2,u=Math.abs(new Date().getTime()-n.getTime())<3e5),isNaN(o)||dl(n,o-(24+n.getHours()-n.getUTCHours())%24))},[n,i,u,o]}class Yc extends De{constructor(e){super(),Pe(this,e,j1,U1,$e,{timestamp:0,fullTimeColor:1,offset:3})}}function H1(t){let e,l,n;return{c(){e=Se("svg"),l=Se("path"),n=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),r(n,"stroke-linecap","round"),r(n,"stroke-linejoin","round"),r(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(i,o){C(i,e,o),s(e,l),s(e,n)},p:_e,i:_e,o:_e,d(i){i&&y(e)}}}class W1 extends De{constructor(e){super(),Pe(this,e,null,H1,$e,{})}}function z1(t){let e,l;return{c(){e=Se("svg"),l=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){C(n,e,i),s(e,l)},p:_e,i:_e,o:_e,d(n){n&&y(e)}}}class G1 extends De{constructor(e){super(),Pe(this,e,null,z1,$e,{})}}function V1(t){let e,l;return{c(){e=Se("svg"),l=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){C(n,e,i),s(e,l)},p:_e,i:_e,o:_e,d(n){n&&y(e)}}}class Bt extends De{constructor(e){super(),Pe(this,e,null,V1,$e,{})}}function K1(t){let e,l;return{c(){e=Se("svg"),l=Se("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){C(n,e,i),s(e,l)},p:_e,i:_e,o:_e,d(n){n&&y(e)}}}class Qc extends De{constructor(e){super(),Pe(this,e,null,K1,$e,{})}}function Y1(t){let e,l,n=t[1].version+"",i;return{c(){e=S("AMS reader "),l=m("span"),i=S(n)},m(o,u){C(o,e,u),C(o,l,u),s(l,i)},p(o,u){u&2&&n!==(n=o[1].version+"")&&X(i,n)},d(o){o&&y(e),o&&y(l)}}}function Ha(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=S(l),i=S("°C"),r(e,"class","flex-none my-auto")},m(o,u){C(o,e,u),s(e,n),s(e,i)},p(o,u){u&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&X(n,l)},d(o){o&&y(e)}}}function Wa(t){let e,l="HAN: "+Oa(t[0].he),n;return{c(){e=m("div"),n=S(l),r(e,"class","bd-red")},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Oa(i[0].he))&&X(n,l)},d(i){i&&y(e)}}}function za(t){let e,l="MQTT: "+Ra(t[0].me),n;return{c(){e=m("div"),n=S(l),r(e,"class","bd-red")},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+Ra(i[0].me))&&X(n,l)},d(i){i&&y(e)}}}function Ga(t){let e,l="Pricps: "+La(t[0].ee),n;return{c(){e=m("div"),n=S(l),r(e,"class","bd-red")},m(i,o){C(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="Pricps: "+La(i[0].ee))&&X(n,l)},d(i){i&&y(e)}}}function Va(t){let e,l,n,i,o,u;return l=new ol({props:{to:"/configuration",$$slots:{default:[Q1]},$$scope:{ctx:t}}}),o=new ol({props:{to:"/status",$$slots:{default:[X1]},$$scope:{ctx:t}}}),{c(){e=m("div"),re(l.$$.fragment),n=b(),i=m("div"),re(o.$$.fragment),r(e,"class","flex-none px-1 mt-1"),r(e,"title","Configuration"),r(i,"class","flex-none px-1 mt-1"),r(i,"title","Device information")},m(a,f){C(a,e,f),se(l,e,null),C(a,n,f),C(a,i,f),se(o,i,null),u=!0},i(a){u||(O(l.$$.fragment,a),O(o.$$.fragment,a),u=!0)},o(a){B(l.$$.fragment,a),B(o.$$.fragment,a),u=!1},d(a){a&&y(e),oe(l),a&&y(n),a&&y(i),oe(o)}}}function Q1(t){let e,l;return e=new W1({}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function X1(t){let e,l;return e=new G1({}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function Ka(t){let e,l,n,i,o;const u=[J1,Z1],a=[];function f(c,p){return c[1].security==0||c[0].a?0:1}return l=f(t),n=a[l]=u[l](t),{c(){e=m("div"),n.c(),r(e,"class","flex-none mr-3 text-yellow-500"),r(e,"title",i="New version: "+t[2].tag_name)},m(c,p){C(c,e,p),a[l].m(e,null),o=!0},p(c,p){let _=l;l=f(c),l===_?a[l].p(c,p):(Ie(),B(a[_],1,1,()=>{a[_]=null}),Oe(),n=a[l],n?n.p(c,p):(n=a[l]=u[l](c),n.c()),O(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+c[2].tag_name))&&r(e,"title",i)},i(c){o||(O(n),o=!0)},o(c){B(n),o=!1},d(c){c&&y(e),a[l].d()}}}function Z1(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=S("New version: "),i=S(n)},m(o,u){C(o,e,u),s(e,l),s(e,i)},p(o,u){u&4&&n!==(n=o[2].tag_name+"")&&X(i,n)},i:_e,o:_e,d(o){o&&y(e)}}}function J1(t){let e,l,n,i=t[2].tag_name+"",o,u,a,f,c,p;return a=new Qc({}),{c(){e=m("button"),l=m("span"),n=S("New version: "),o=S(i),u=b(),re(a.$$.fragment),r(l,"class","mt-1"),r(e,"class","flex")},m(_,h){C(_,e,h),s(e,l),s(l,n),s(l,o),s(e,u),se(a,e,null),f=!0,c||(p=le(e,"click",t[3]),c=!0)},p(_,h){(!f||h&4)&&i!==(i=_[2].tag_name+"")&&X(o,i)},i(_){f||(O(a.$$.fragment,_),f=!0)},o(_){B(a.$$.fragment,_),f=!1},d(_){_&&y(e),oe(a),c=!1,p()}}}function x1(t){let e,l,n,i,o,u,a,f,c,p,_,h,d=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue,x,W,U,ke,He,Be,We;i=new ol({props:{to:"/",$$slots:{default:[Y1]},$$scope:{ctx:t}}}),f=new R1({props:{epoch:t[0].u}});let Ne=t[0].t>-50&&Ha(t);M=new fn({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:jl(t[1].booting?2:t[0].em)}}),F=new fn({props:{title:"HAN",text:"HAN",color:jl(t[1].booting?9:t[0].hm)}}),I=new fn({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:jl(t[1].booting?9:t[0].wm)}}),L=new fn({props:{title:"MQTT",text:"MQTT",color:jl(t[1].booting?9:t[0].mm)}});let ge=(t[0].he<0||t[0].he>0)&&Wa(t),Re=t[0].me<0&&za(t),Me=(t[0].ee>0||t[0].ee<0)&&Ga(t);ue=new Yc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),offset:t[1].clock_offset,fullTimeColor:"text-red-500"}});let T=t[1].vndcfg&&t[1].usrcfg&&Va(t);He=new Bt({});let k=t[1].fwconsent===1&&t[2]&&Ka(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),re(i.$$.fragment),o=b(),u=m("div"),a=m("div"),re(f.$$.fragment),c=b(),Ne&&Ne.c(),p=b(),_=m("div"),h=S("Free mem: "),v=S(d),g=S("kb"),A=b(),$=m("div"),re(M.$$.fragment),P=b(),re(F.$$.fragment),E=b(),re(I.$$.fragment),D=b(),re(L.$$.fragment),ie=b(),ge&&ge.c(),H=b(),Re&&Re.c(),K=b(),Me&&Me.c(),G=b(),Y=m("div"),Q=m("div"),z=m("a"),Z=m("img"),j=b(),ee=m("div"),re(ue.$$.fragment),x=b(),T&&T.c(),W=b(),U=m("div"),ke=m("a"),re(He.$$.fragment),Be=b(),k&&k.c(),r(n,"class","flex text-lg text-gray-100 p-2"),r(a,"class","flex-none my-auto"),r(_,"class","flex-none my-auto"),r(u,"class","flex-none my-auto p-2 flex space-x-4"),r($,"class","flex-auto flex-wrap my-auto justify-center p-2"),r(Z,"class","gh-logo"),Xs(Z.src,V=T1)||r(Z,"src",V),r(Z,"alt","GitHub repo"),r(z,"class","float-right"),r(z,"href","https://github.com/UtilitechAS/amsreader-firmware"),r(z,"target","_blank"),r(z,"rel","noreferrer"),r(z,"aria-label","GitHub"),r(Q,"class","flex-none"),r(ee,"class","flex-none my-auto px-2"),r(ke,"href",Ut("")),r(ke,"target","_blank"),r(ke,"rel","noreferrer"),r(U,"class","flex-none px-1 mt-1"),r(U,"title","Documentation"),r(Y,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),r(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),r(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(w,N){C(w,e,N),s(e,l),s(l,n),se(i,n,null),s(l,o),s(l,u),s(u,a),se(f,a,null),s(u,c),Ne&&Ne.m(u,null),s(u,p),s(u,_),s(_,h),s(_,v),s(_,g),s(l,A),s(l,$),se(M,$,null),s($,P),se(F,$,null),s($,E),se(I,$,null),s($,D),se(L,$,null),s(l,ie),ge&&ge.m(l,null),s(l,H),Re&&Re.m(l,null),s(l,K),Me&&Me.m(l,null),s(l,G),s(l,Y),s(Y,Q),s(Q,z),s(z,Z),s(Y,j),s(Y,ee),se(ue,ee,null),s(Y,x),T&&T.m(Y,null),s(Y,W),s(Y,U),s(U,ke),se(He,ke,null),s(Y,Be),k&&k.m(Y,null),We=!0},p(w,[N]){const R={};N&18&&(R.$$scope={dirty:N,ctx:w}),i.$set(R);const J={};N&1&&(J.epoch=w[0].u),f.$set(J),w[0].t>-50?Ne?Ne.p(w,N):(Ne=Ha(w),Ne.c(),Ne.m(u,p)):Ne&&(Ne.d(1),Ne=null),(!We||N&1)&&d!==(d=(w[0].m?(w[0].m/1e3).toFixed(1):"-")+"")&&X(v,d);const te={};N&3&&(te.text=w[1].booting?"Booting":w[0].v>2?w[0].v.toFixed(2)+"V":"ESP"),N&3&&(te.color=jl(w[1].booting?2:w[0].em)),M.$set(te);const fe={};N&3&&(fe.color=jl(w[1].booting?9:w[0].hm)),F.$set(fe);const de={};N&1&&(de.text=w[0].r?w[0].r.toFixed(0)+"dBm":"WiFi"),N&3&&(de.color=jl(w[1].booting?9:w[0].wm)),I.$set(de);const we={};N&3&&(we.color=jl(w[1].booting?9:w[0].mm)),L.$set(we),w[0].he<0||w[0].he>0?ge?ge.p(w,N):(ge=Wa(w),ge.c(),ge.m(l,H)):ge&&(ge.d(1),ge=null),w[0].me<0?Re?Re.p(w,N):(Re=za(w),Re.c(),Re.m(l,K)):Re&&(Re.d(1),Re=null),w[0].ee>0||w[0].ee<0?Me?Me.p(w,N):(Me=Ga(w),Me.c(),Me.m(l,G)):Me&&(Me.d(1),Me=null);const Ee={};N&1&&(Ee.timestamp=w[0].c?new Date(w[0].c*1e3):new Date(0)),N&2&&(Ee.offset=w[1].clock_offset),ue.$set(Ee),w[1].vndcfg&&w[1].usrcfg?T?N&2&&O(T,1):(T=Va(w),T.c(),O(T,1),T.m(Y,W)):T&&(Ie(),B(T,1,1,()=>{T=null}),Oe()),w[1].fwconsent===1&&w[2]?k?(k.p(w,N),N&6&&O(k,1)):(k=Ka(w),k.c(),O(k,1),k.m(Y,null)):k&&(Ie(),B(k,1,1,()=>{k=null}),Oe())},i(w){We||(O(i.$$.fragment,w),O(f.$$.fragment,w),O(M.$$.fragment,w),O(F.$$.fragment,w),O(I.$$.fragment,w),O(L.$$.fragment,w),O(ue.$$.fragment,w),O(T),O(He.$$.fragment,w),O(k),We=!0)},o(w){B(i.$$.fragment,w),B(f.$$.fragment,w),B(M.$$.fragment,w),B(F.$$.fragment,w),B(I.$$.fragment,w),B(L.$$.fragment,w),B(ue.$$.fragment,w),B(T),B(He.$$.fragment,w),B(k),We=!1},d(w){w&&y(e),oe(i),oe(f),Ne&&Ne.d(),oe(M),oe(F),oe(I),oe(L),ge&&ge.d(),Re&&Re.d(),Me&&Me.d(),oe(ue),T&&T.d(),oe(He),k&&k.d()}}}function em(t,e,l){let{data:n={}}=e,i={},o={};function u(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!oi(i.board)||confirm(Cs(ve(i.chip,i.board))))&&(Yt.update(a=>(a.upgrading=!0,a)),Vc(o.tag_name))}return Yt.subscribe(a=>{l(1,i=a),a.fwconsent===1&&C1()}),So.subscribe(a=>{l(2,o=Kc(i.version,a))}),t.$$set=a=>{"data"in a&&l(0,n=a.data)},[n,i,o,u]}class tm extends De{constructor(e){super(),Pe(this,e,em,x1,$e,{data:0})}}function lm(t){let e,l,n,i;return{c(){e=Se("svg"),l=Se("path"),n=Se("path"),r(l,"d",Qs(150,150,115,210,510)),r(l,"stroke","rgba(128, 128, 128, 0.15)"),r(l,"fill","none"),r(l,"stroke-width","55"),r(n,"d",i=Qs(150,150,115,210,210+300*t[0]/100)),r(n,"stroke",t[1]),r(n,"fill","none"),r(n,"stroke-width","55"),r(e,"viewBox","0 0 300 300"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"height","100%")},m(o,u){C(o,e,u),s(e,l),s(e,n)},p(o,[u]){u&1&&i!==(i=Qs(150,150,115,210,210+300*o[0]/100))&&r(n,"d",i),u&2&&r(n,"stroke",o[1])},i:_e,o:_e,d(o){o&&y(e)}}}function Ya(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function Qs(t,e,l,n,i){var o=Ya(t,e,l,i),u=Ya(t,e,l,n),a=i-n<=180?"0":"1",f=["M",o.x,o.y,"A",l,l,0,a,0,u.x,u.y].join(" ");return f}function nm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class im extends De{constructor(e){super(),Pe(this,e,nm,lm,$e,{pct:0,color:1})}}function Qa(t){let e,l,n,i,o,u,a,f;return{c(){e=m("br"),l=b(),n=m("span"),i=S(t[3]),o=b(),u=m("span"),a=S(t[4]),f=S("/kWh"),r(n,"class","pl-sub"),r(u,"class","pl-snt")},m(c,p){C(c,e,p),C(c,l,p),C(c,n,p),s(n,i),C(c,o,p),C(c,u,p),s(u,a),s(u,f)},p(c,p){p&8&&X(i,c[3]),p&16&&X(a,c[4])},d(c){c&&y(e),c&&y(l),c&&y(n),c&&y(o),c&&y(u)}}}function sm(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A;l=new im({props:{pct:t[6],color:t[5](t[6])}});let $=t[3]&&Qa(t);return{c(){e=m("div"),re(l.$$.fragment),n=b(),i=m("span"),o=m("span"),u=S(t[2]),a=b(),f=m("br"),c=b(),p=m("span"),_=S(t[0]),h=b(),d=m("span"),v=S(t[1]),g=b(),$&&$.c(),r(o,"class","pl-lab"),r(p,"class","pl-val"),r(d,"class","pl-unt"),r(i,"class","pl-ov"),r(e,"class","pl-root")},m(M,P){C(M,e,P),se(l,e,null),s(e,n),s(e,i),s(i,o),s(o,u),s(i,a),s(i,f),s(i,c),s(i,p),s(p,_),s(i,h),s(i,d),s(d,v),s(i,g),$&&$.m(i,null),A=!0},p(M,[P]){const F={};P&64&&(F.pct=M[6]),P&96&&(F.color=M[5](M[6])),l.$set(F),(!A||P&4)&&X(u,M[2]),(!A||P&1)&&X(_,M[0]),(!A||P&2)&&X(v,M[1]),M[3]?$?$.p(M,P):($=Qa(M),$.c(),$.m(i,null)):$&&($.d(1),$=null)},i(M){A||(O(l.$$.fragment,M),A=!0)},o(M){B(l.$$.fragment,M),A=!1},d(M){M&&y(e),oe(l),$&&$.d()}}}function om(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:u}=e,{sub:a=""}=e,{subunit:f=""}=e,{colorFn:c}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,u=_.label),"sub"in _&&l(3,a=_.sub),"subunit"in _&&l(4,f=_.subunit),"colorFn"in _&&l(5,c=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,u,a,f,c,p,i]}class Xc extends De{constructor(e){super(),Pe(this,e,om,sm,$e,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function Xa(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Za(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function Ja(t,e,l){const n=t.slice();return n[13]=e[l],n}function xa(t){let e,l,n,i,o,u=t[0].title&&eu(t),a=t[0].y.ticks,f=[];for(let d=0;d20||t[11]%2==0)&&iu(t);return{c(){e=Se("g"),n&&n.c(),r(e,"class","tick"),r(e,"transform",l="translate("+t[5](t[11])+","+t[4]+")")},m(i,o){C(i,e,o),n&&n.m(e,null)},p(i,o){i[3]>20||i[11]%2==0?n?n.p(i,o):(n=iu(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o&48&&l!==(l="translate("+i[5](i[11])+","+i[4]+")")&&r(e,"transform",l)},d(i){i&&y(e),n&&n.d()}}}function iu(t){let e,l=t[9].label+"",n,i;return{c(){e=Se("text"),n=S(l),r(e,"x",i=t[3]/2),r(e,"y","-4")},m(o,u){C(o,e,u),s(e,n)},p(o,u){u&1&&l!==(l=o[9].label+"")&&X(n,l),u&8&&i!==(i=o[3]/2)&&r(e,"x",i)},d(o){o&&y(e)}}}function su(t){let e=!isNaN(t[5](t[11])),l,n=e&&nu(t);return{c(){n&&n.c(),l=Ve()},m(i,o){n&&n.m(i,o),C(i,l,o)},p(i,o){o&32&&(e=!isNaN(i[5](i[11]))),e?n?n.p(i,o):(n=nu(i),n.c(),n.m(l.parentNode,l)):n&&(n.d(1),n=null)},d(i){n&&n.d(i),i&&y(l)}}}function ou(t){let e,l,n=t[9].value!==void 0&&ru(t),i=t[9].value2>1e-4&&fu(t);return{c(){e=Se("g"),n&&n.c(),l=Se("g"),i&&i.c()},m(o,u){C(o,e,u),n&&n.m(e,null),C(o,l,u),i&&i.m(l,null)},p(o,u){o[9].value!==void 0?n?n.p(o,u):(n=ru(o),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,u):(i=fu(o),i.c(),i.m(l,null)):i&&(i.d(1),i=null)},d(o){o&&y(e),n&&n.d(),o&&y(l),i&&i.d()}}}function ru(t){let e,l,n,i,o,u,a,f=t[3]>15&&au(t);return{c(){e=Se("rect"),f&&f.c(),a=Ve(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](t[9].value)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),r(e,"fill",u=t[9].color)},m(c,p){C(c,e,p),f&&f.m(c,p),C(c,a,p)},p(c,p){p&32&&l!==(l=c[5](c[11])+2)&&r(e,"x",l),p&65&&n!==(n=c[6](c[9].value))&&r(e,"y",n),p&8&&i!==(i=c[3]-4)&&r(e,"width",i),p&65&&o!==(o=c[6](c[0].y.min)-c[6](Math.min(c[0].y.min,0)+c[9].value))&&r(e,"height",o),p&1&&u!==(u=c[9].color)&&r(e,"fill",u),c[3]>15?f?f.p(c,p):(f=au(c),f.c(),f.m(a.parentNode,a)):f&&(f.d(1),f=null)},d(c){c&&y(e),f&&f.d(c),c&&y(a)}}}function au(t){let e,l=t[9].label+"",n,i,o,u,a,f,c=t[9].title&&uu(t);return{c(){e=Se("text"),n=S(l),c&&c.c(),f=Ve(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor",o=t[3]t[6](0)-t[7]?t[9].color:"white"),r(e,"transform",a="translate("+(t[5](t[11])+t[3]/2)+" "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10)+") rotate("+(t[3]p[6](0)-p[7]?p[9].color:"white")&&r(e,"fill",u),_&233&&a!==(a="translate("+(p[5](p[11])+p[3]/2)+" "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)+") rotate("+(p[3]15&&cu(t);return{c(){e=Se("rect"),f&&f.c(),a=Ve(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](0)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),r(e,"fill",u=t[9].color2?t[9].color2:t[9].color)},m(c,p){C(c,e,p),f&&f.m(c,p),C(c,a,p)},p(c,p){p&32&&l!==(l=c[5](c[11])+2)&&r(e,"x",l),p&64&&n!==(n=c[6](0))&&r(e,"y",n),p&8&&i!==(i=c[3]-4)&&r(e,"width",i),p&65&&o!==(o=c[6](c[0].y.min)-c[6](c[0].y.min+c[9].value2))&&r(e,"height",o),p&1&&u!==(u=c[9].color2?c[9].color2:c[9].color)&&r(e,"fill",u),c[3]>15?f?f.p(c,p):(f=cu(c),f.c(),f.m(a.parentNode,a)):f&&(f.d(1),f=null)},d(c){c&&y(e),f&&f.d(c),c&&y(a)}}}function cu(t){let e,l=t[9].label2+"",n,i,o,u,a,f=t[9].title2&&mu(t);return{c(){e=Se("text"),n=S(l),f&&f.c(),a=Ve(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor","middle"),r(e,"fill",o=t[6](-t[9].value2)t[8].call(e))},m(i,o){C(i,e,o),n&&n.m(e,null),l=ic(e,t[8].bind(e))},p(i,[o]){i[0].x.ticks&&i[0].points&&i[4]?n?n.p(i,o):(n=xa(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null)},i:_e,o:_e,d(i){i&&y(e),n&&n.d(),l()}}}let cn=30;function am(t,e,l){let{config:n}=e,i,o,u,a,f,c,p;function _(){i=this.clientWidth,o=this.clientHeight,l(1,i),l(2,o)}return t.$$set=h=>{"config"in h&&l(0,n=h.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,c=o-(n.title?20:0));let h=i-(n.padding.left+n.padding.right);l(3,u=h/n.points.length),l(7,p=un.y.max?g=n.padding.bottom:vc||g<0?0:g})}},[n,i,o,u,c,a,f,p,_]}class pn extends De{constructor(e){super(),Pe(this,e,am,rm,$e,{config:0})}}function um(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function fm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:u}=e,a={};function f(c){return{label:be(c)+"V",title:c.toFixed(1)+" V",value:isNaN(c)?0:c,color:k1(c||0)}}return t.$$set=c=>{"u1"in c&&l(1,n=c.u1),"u2"in c&&l(2,i=c.u2),"u3"in c&&l(3,o=c.u3),"ds"in c&&l(4,u=c.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let c=[],p=[];n>0&&(c.push({label:u===1?"L1-L2":"L1"}),p.push(f(n))),i>0&&(c.push({label:u===1?"L1-L3":"L2"}),p.push(f(i))),o>0&&(c.push({label:u===1?"L2-L3":"L3"}),p.push(f(o))),l(0,a={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:c},points:p})}},[a,n,i,o,u]}class cm extends De{constructor(e){super(),Pe(this,e,fm,um,$e,{u1:1,u2:2,u3:3,ds:4})}}function mm(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function pm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:u}=e,{i2:a}=e,{i3:f}=e,{max:c}=e,p={};function _(h){return{label:be(h)+"A",title:h.toFixed(1)+" A",value:isNaN(h)?0:h,color:Rc(h?h/c*100:0)}}return t.$$set=h=>{"u1"in h&&l(1,n=h.u1),"u2"in h&&l(2,i=h.u2),"u3"in h&&l(3,o=h.u3),"i1"in h&&l(4,u=h.i1),"i2"in h&&l(5,a=h.i2),"i3"in h&&l(6,f=h.i3),"max"in h&&l(7,c=h.max)},t.$$.update=()=>{if(t.$$.dirty&254){let h=[],d=[];n>0&&(h.push({label:"L1"}),d.push(_(u))),i>0&&(h.push({label:"L2"}),d.push(_(a))),o>0&&(h.push({label:"L3"}),d.push(_(f))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:c,ticks:[{value:0,label:"0%"},{value:c/4,label:"25%"},{value:c/2,label:"50%"},{value:c/4*3,label:"75%"},{value:c,label:"100%"}]},x:{ticks:h},points:d})}},[p,n,i,o,u,a,f,c]}class _m extends De{constructor(e){super(),Pe(this,e,pm,mm,$e,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function dm(t){let e,l,n,i,o,u,a,f=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",c,p,_,h,d,v,g=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",A,$,M,P,F,E,I,D=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",L,ie,H,K,G,Y,Q=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",z,Z;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=b(),i=m("div"),o=m("div"),o.textContent="Instant in",u=b(),a=m("div"),c=S(f),p=S(" VAr"),_=b(),h=m("div"),h.textContent="Instant out",d=b(),v=m("div"),A=S(g),$=S(" VAr"),M=b(),P=m("div"),F=m("div"),F.textContent="Total in",E=b(),I=m("div"),L=S(D),ie=S(" kVArh"),H=b(),K=m("div"),K.textContent="Total out",G=b(),Y=m("div"),z=S(Q),Z=S(" kVArh"),r(a,"class","text-right"),r(v,"class","text-right"),r(i,"class","grid grid-cols-2 mt-4"),r(I,"class","text-right"),r(Y,"class","text-right"),r(P,"class","grid grid-cols-2 mt-4"),r(e,"class","mx-2 text-sm")},m(V,j){C(V,e,j),s(e,l),s(e,n),s(e,i),s(i,o),s(i,u),s(i,a),s(a,c),s(a,p),s(i,_),s(i,h),s(i,d),s(i,v),s(v,A),s(v,$),s(e,M),s(e,P),s(P,F),s(P,E),s(P,I),s(I,L),s(I,ie),s(P,H),s(P,K),s(P,G),s(P,Y),s(Y,z),s(Y,Z)},p(V,[j]){j&1&&f!==(f=(typeof V[0]<"u"?V[0].toFixed(0):"-")+"")&&X(c,f),j&2&&g!==(g=(typeof V[1]<"u"?V[1].toFixed(0):"-")+"")&&X(A,g),j&4&&D!==(D=(typeof V[2]<"u"?V[2].toFixed(1):"-")+"")&&X(L,D),j&8&&Q!==(Q=(typeof V[3]<"u"?V[3].toFixed(1):"-")+"")&&X(z,Q)},i:_e,o:_e,d(V){V&&y(e)}}}function vm(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:u}=e;return t.$$set=a=>{"importInstant"in a&&l(0,n=a.importInstant),"exportInstant"in a&&l(1,i=a.exportInstant),"importTotal"in a&&l(2,o=a.importTotal),"exportTotal"in a&&l(3,u=a.exportTotal)},[n,i,o,u]}class hm extends De{constructor(e){super(),Pe(this,e,vm,dm,$e,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function _u(t){let e;function l(o,u){return o[3]?gm:bm}let n=l(t),i=n(t);return{c(){i.c(),e=Ve()},m(o,u){i.m(o,u),C(o,e,u)},p(o,u){n===(n=l(o))&&i?i.p(o,u):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&y(e)}}}function bm(t){let e,l,n,i,o,u,a=be(t[1].h.u,2)+"",f,c,p,_,h,d,v=be(t[1].d.u,1)+"",g,A,$,M,P,F,E=be(t[1].m.u)+"",I,D,L,ie,H,K,G=be(t[0].last_month.u)+"",Y,Q,z,Z,V=t[4]&&du(t);return{c(){e=m("strong"),e.textContent="Consumption",l=b(),n=m("div"),i=m("div"),i.textContent="Hour",o=b(),u=m("div"),f=S(a),c=S(" kWh"),p=b(),_=m("div"),_.textContent="Day",h=b(),d=m("div"),g=S(v),A=S(" kWh"),$=b(),M=m("div"),M.textContent="Month",P=b(),F=m("div"),I=S(E),D=S(" kWh"),L=b(),ie=m("div"),ie.textContent="Last month",H=b(),K=m("div"),Y=S(G),Q=S(" kWh"),z=b(),V&&V.c(),Z=Ve(),r(u,"class","text-right"),r(d,"class","text-right"),r(F,"class","text-right"),r(K,"class","text-right"),r(n,"class","grid grid-cols-2 mb-3")},m(j,ee){C(j,e,ee),C(j,l,ee),C(j,n,ee),s(n,i),s(n,o),s(n,u),s(u,f),s(u,c),s(n,p),s(n,_),s(n,h),s(n,d),s(d,g),s(d,A),s(n,$),s(n,M),s(n,P),s(n,F),s(F,I),s(F,D),s(n,L),s(n,ie),s(n,H),s(n,K),s(K,Y),s(K,Q),C(j,z,ee),V&&V.m(j,ee),C(j,Z,ee)},p(j,ee){ee&2&&a!==(a=be(j[1].h.u,2)+"")&&X(f,a),ee&2&&v!==(v=be(j[1].d.u,1)+"")&&X(g,v),ee&2&&E!==(E=be(j[1].m.u)+"")&&X(I,E),ee&1&&G!==(G=be(j[0].last_month.u)+"")&&X(Y,G),j[4]?V?V.p(j,ee):(V=du(j),V.c(),V.m(Z.parentNode,Z)):V&&(V.d(1),V=null)},d(j){j&&y(e),j&&y(l),j&&y(n),j&&y(z),V&&V.d(j),j&&y(Z)}}}function gm(t){let e,l,n,i,o,u,a=be(t[1].h.u,2)+"",f,c,p,_,h,d,v,g=be(t[1].d.u,1)+"",A,$,M,P,F,E,I,D=be(t[1].m.u)+"",L,ie,H,K,G,Y,Q,z=be(t[0].last_month.u)+"",Z,V,j,ee,ue,x,W,U,ke,He,Be,We=be(t[1].h.p,2)+"",Ne,ge,Re,Me,T,k,w,N=be(t[1].d.p,1)+"",R,J,te,fe,de,we,Ee,ae=be(t[1].m.p)+"",Ce,Je,Et,st,ht,lt,At,Ye=be(t[0].last_month.p)+"",Qt,Ht,bt,ze,xe=t[4]&&vu(t),Xe=t[4]&&hu(t),Ue=t[4]&&bu(t),qe=t[4]&&gu(t),et=t[4]&&ku(t),Ae=t[4]&&wu(t),Le=t[4]&&yu(t),pe=t[4]&&Cu(t);return{c(){e=m("strong"),e.textContent="Import",l=b(),n=m("div"),i=m("div"),i.textContent="Hour",o=b(),u=m("div"),f=S(a),c=S(" kWh"),p=b(),xe&&xe.c(),_=b(),h=m("div"),h.textContent="Day",d=b(),v=m("div"),A=S(g),$=S(" kWh"),M=b(),Xe&&Xe.c(),P=b(),F=m("div"),F.textContent="Month",E=b(),I=m("div"),L=S(D),ie=S(" kWh"),H=b(),Ue&&Ue.c(),K=b(),G=m("div"),G.textContent="Last mo.",Y=b(),Q=m("div"),Z=S(z),V=S(" kWh"),j=b(),qe&&qe.c(),ue=b(),x=m("strong"),x.textContent="Export",W=b(),U=m("div"),ke=m("div"),ke.textContent="Hour",He=b(),Be=m("div"),Ne=S(We),ge=S(" kWh"),Re=b(),et&&et.c(),Me=b(),T=m("div"),T.textContent="Day",k=b(),w=m("div"),R=S(N),J=S(" kWh"),te=b(),Ae&&Ae.c(),fe=b(),de=m("div"),de.textContent="Month",we=b(),Ee=m("div"),Ce=S(ae),Je=S(" kWh"),Et=b(),Le&&Le.c(),st=b(),ht=m("div"),ht.textContent="Last mo.",lt=b(),At=m("div"),Qt=S(Ye),Ht=S(" kWh"),bt=b(),pe&&pe.c(),r(u,"class","text-right"),r(v,"class","text-right"),r(I,"class","text-right"),r(Q,"class","text-right"),r(n,"class",ee="grid grid-cols-"+t[5]+" mb-3"),r(Be,"class","text-right"),r(w,"class","text-right"),r(Ee,"class","text-right"),r(At,"class","text-right"),r(U,"class",ze="grid grid-cols-"+t[5])},m(ce,ye){C(ce,e,ye),C(ce,l,ye),C(ce,n,ye),s(n,i),s(n,o),s(n,u),s(u,f),s(u,c),s(n,p),xe&&xe.m(n,null),s(n,_),s(n,h),s(n,d),s(n,v),s(v,A),s(v,$),s(n,M),Xe&&Xe.m(n,null),s(n,P),s(n,F),s(n,E),s(n,I),s(I,L),s(I,ie),s(n,H),Ue&&Ue.m(n,null),s(n,K),s(n,G),s(n,Y),s(n,Q),s(Q,Z),s(Q,V),s(n,j),qe&&qe.m(n,null),C(ce,ue,ye),C(ce,x,ye),C(ce,W,ye),C(ce,U,ye),s(U,ke),s(U,He),s(U,Be),s(Be,Ne),s(Be,ge),s(U,Re),et&&et.m(U,null),s(U,Me),s(U,T),s(U,k),s(U,w),s(w,R),s(w,J),s(U,te),Ae&&Ae.m(U,null),s(U,fe),s(U,de),s(U,we),s(U,Ee),s(Ee,Ce),s(Ee,Je),s(U,Et),Le&&Le.m(U,null),s(U,st),s(U,ht),s(U,lt),s(U,At),s(At,Qt),s(At,Ht),s(U,bt),pe&&pe.m(U,null)},p(ce,ye){ye&2&&a!==(a=be(ce[1].h.u,2)+"")&&X(f,a),ce[4]?xe?xe.p(ce,ye):(xe=vu(ce),xe.c(),xe.m(n,_)):xe&&(xe.d(1),xe=null),ye&2&&g!==(g=be(ce[1].d.u,1)+"")&&X(A,g),ce[4]?Xe?Xe.p(ce,ye):(Xe=hu(ce),Xe.c(),Xe.m(n,P)):Xe&&(Xe.d(1),Xe=null),ye&2&&D!==(D=be(ce[1].m.u)+"")&&X(L,D),ce[4]?Ue?Ue.p(ce,ye):(Ue=bu(ce),Ue.c(),Ue.m(n,K)):Ue&&(Ue.d(1),Ue=null),ye&1&&z!==(z=be(ce[0].last_month.u)+"")&&X(Z,z),ce[4]?qe?qe.p(ce,ye):(qe=gu(ce),qe.c(),qe.m(n,null)):qe&&(qe.d(1),qe=null),ye&32&&ee!==(ee="grid grid-cols-"+ce[5]+" mb-3")&&r(n,"class",ee),ye&2&&We!==(We=be(ce[1].h.p,2)+"")&&X(Ne,We),ce[4]?et?et.p(ce,ye):(et=ku(ce),et.c(),et.m(U,Me)):et&&(et.d(1),et=null),ye&2&&N!==(N=be(ce[1].d.p,1)+"")&&X(R,N),ce[4]?Ae?Ae.p(ce,ye):(Ae=wu(ce),Ae.c(),Ae.m(U,fe)):Ae&&(Ae.d(1),Ae=null),ye&2&&ae!==(ae=be(ce[1].m.p)+"")&&X(Ce,ae),ce[4]?Le?Le.p(ce,ye):(Le=yu(ce),Le.c(),Le.m(U,st)):Le&&(Le.d(1),Le=null),ye&1&&Ye!==(Ye=be(ce[0].last_month.p)+"")&&X(Qt,Ye),ce[4]?pe?pe.p(ce,ye):(pe=Cu(ce),pe.c(),pe.m(U,null)):pe&&(pe.d(1),pe=null),ye&32&&ze!==(ze="grid grid-cols-"+ce[5])&&r(U,"class",ze)},d(ce){ce&&y(e),ce&&y(l),ce&&y(n),xe&&xe.d(),Xe&&Xe.d(),Ue&&Ue.d(),qe&&qe.d(),ce&&y(ue),ce&&y(x),ce&&y(W),ce&&y(U),et&&et.d(),Ae&&Ae.d(),Le&&Le.d(),pe&&pe.d()}}}function du(t){let e,l,n,i,o,u,a=be(t[1].h.c,2)+"",f,c,p,_,h,d,v,g=be(t[1].d.c,1)+"",A,$,M,P,F,E,I,D=be(t[1].m.c)+"",L,ie,H,K,G,Y,Q,z=be(t[0].last_month.c)+"",Z,V,j;return{c(){e=m("strong"),e.textContent="Cost",l=b(),n=m("div"),i=m("div"),i.textContent="Hour",o=b(),u=m("div"),f=S(a),c=b(),p=S(t[2]),_=b(),h=m("div"),h.textContent="Day",d=b(),v=m("div"),A=S(g),$=b(),M=S(t[2]),P=b(),F=m("div"),F.textContent="Month",E=b(),I=m("div"),L=S(D),ie=b(),H=S(t[2]),K=b(),G=m("div"),G.textContent="Last month",Y=b(),Q=m("div"),Z=S(z),V=b(),j=S(t[2]),r(u,"class","text-right"),r(v,"class","text-right"),r(I,"class","text-right"),r(Q,"class","text-right"),r(n,"class","grid grid-cols-2")},m(ee,ue){C(ee,e,ue),C(ee,l,ue),C(ee,n,ue),s(n,i),s(n,o),s(n,u),s(u,f),s(u,c),s(u,p),s(n,_),s(n,h),s(n,d),s(n,v),s(v,A),s(v,$),s(v,M),s(n,P),s(n,F),s(n,E),s(n,I),s(I,L),s(I,ie),s(I,H),s(n,K),s(n,G),s(n,Y),s(n,Q),s(Q,Z),s(Q,V),s(Q,j)},p(ee,ue){ue&2&&a!==(a=be(ee[1].h.c,2)+"")&&X(f,a),ue&4&&X(p,ee[2]),ue&2&&g!==(g=be(ee[1].d.c,1)+"")&&X(A,g),ue&4&&X(M,ee[2]),ue&2&&D!==(D=be(ee[1].m.c)+"")&&X(L,D),ue&4&&X(H,ee[2]),ue&1&&z!==(z=be(ee[0].last_month.c)+"")&&X(Z,z),ue&4&&X(j,ee[2])},d(ee){ee&&y(e),ee&&y(l),ee&&y(n)}}}function vu(t){let e,l=be(t[1].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].h.c,2)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function hu(t){let e,l=be(t[1].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].d.c,1)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function bu(t){let e,l=be(t[1].m.c)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].m.c)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function gu(t){let e,l=be(t[0].last_month.c)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&1&&l!==(l=be(u[0].last_month.c)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function ku(t){let e,l=be(t[1].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].h.i,2)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function wu(t){let e,l=be(t[1].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].d.i,1)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function yu(t){let e,l=be(t[1].m.i)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&2&&l!==(l=be(u[1].m.i)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function Cu(t){let e,l=be(t[0].last_month.i)+"",n,i,o;return{c(){e=m("div"),n=S(l),i=b(),o=S(t[2]),r(e,"class","text-right")},m(u,a){C(u,e,a),s(e,n),s(e,i),s(e,o)},p(u,a){a&1&&l!==(l=be(u[0].last_month.i)+"")&&X(n,l),a&4&&X(o,u[2])},d(u){u&&y(e)}}}function km(t){let e,l,n,i,o,u,a=t[1]&&_u(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=b(),i=m("br"),o=m("br"),u=b(),a&&a.c(),r(e,"class","mx-2 text-sm")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),s(e,u),a&&a.m(e,null)},p(f,[c]){f[1]?a?a.p(f,c):(a=_u(f),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},i:_e,o:_e,d(f){f&&y(e),a&&a.d()}}}function wm(t,e,l){let{sysinfo:n}=e,{data:i}=e,{currency:o}=e,{hasExport:u}=e,a=!1,f=3;return t.$$set=c=>{"sysinfo"in c&&l(0,n=c.sysinfo),"data"in c&&l(1,i=c.data),"currency"in c&&l(2,o=c.currency),"hasExport"in c&&l(3,u=c.hasExport)},t.$$.update=()=>{t.$$.dirty&18&&(l(4,a=i&&i.h&&(Math.abs(i.h.c)>.01||Math.abs(i.d.c)>.01||Math.abs(i.m.c)>.01||Math.abs(i.h.i)>.01||Math.abs(i.d.i)>.01||Math.abs(i.m.i)>.01)),l(5,f=a?3:2))},[n,i,o,u,a,f]}class ym extends De{constructor(e){super(),Pe(this,e,wm,km,$e,{sysinfo:0,data:1,currency:2,hasExport:3})}}function Cm(t){let e,l,n=qa(t[0].source)+"",i,o,u,a;return u=new pn({props:{config:t[1]}}),{c(){e=m("a"),l=S("Provided by: "),i=S(n),o=b(),re(u.$$.fragment),r(e,"href","https://transparency.entsoe.eu/"),r(e,"target","_blank"),r(e,"class","text-xs float-right z-40")},m(f,c){C(f,e,c),s(e,l),s(e,i),C(f,o,c),se(u,f,c),a=!0},p(f,[c]){(!a||c&1)&&n!==(n=qa(f[0].source)+"")&&X(i,n);const p={};c&2&&(p.config=f[1]),u.$set(p)},i(f){a||(O(u.$$.fragment,f),a=!0)},o(f){B(u.$$.fragment,f),a=!1},d(f){f&&y(e),f&&y(o),oe(u,f)}}}function Mm(t,e,l){let{json:n}=e,{sysinfo:i}=e,o={},u,a;return t.$$set=f=>{"json"in f&&l(0,n=f.json),"sysinfo"in f&&l(2,i=f.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&29){let f=n.currency,c=new Date().getUTCHours(),p=0,_=0,h=0,d=[],v=[],g=[];l(4,a=l(3,u=0));let A=new Date;for(dl(A,i.clock_offset-(24+A.getHours()-A.getUTCHours())%24),p=c;p<24&&(_=n[Fe(h++)],_!=null);p++)v.push({label:Fe(A.getHours())}),g.push(_*100),l(4,a=Math.min(a,_*100)),l(3,u=Math.max(u,_*100)),dl(A,1);for(p=0;p<24&&(_=n[Fe(h++)],_!=null);p++)v.push({label:Fe(A.getHours())}),g.push(_*100),l(4,a=Math.min(a,_*100)),l(3,u=Math.max(u,_*100)),dl(A,1);if(a>-100&&u<100){switch(f){case"NOK":case"SEK":case"DKK":f="øre";break;case"EUR":f="cent";break;default:f=f+"/100"}for(l(4,a*=100),l(3,u*=100),p=0;p=0?E.toFixed(I):"",title:E>=0?E.toFixed(2)+" "+f:"",value:_>=0?Math.abs(_):0,label2:E<0?E.toFixed(I):"",title2:E<0?E.toFixed(2)+" "+f:"",value2:_<0?Math.abs(_):0,color:"#7c3aed"})}let M=Math.max(u,Math.abs(a));if(a<0){l(4,a=Math.min(M/4*-1,a));let E=Math.ceil(Math.abs(a)/M*4),I=a/E;for(p=1;p{"json"in f&&l(1,n=f.json),"sysinfo"in f&&l(2,i=f.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let f=0,c=[],p=[],_=[];l(4,a=l(3,u=0));let h=dl(new Date,-24),d=new Date().getUTCHours();for(dl(h,i.clock_offset-(24+h.getHours()-h.getUTCHours())%24),f=d;f<24;f++){let $=n["i"+Fe(f)],M=n["e"+Fe(f)];$===void 0&&($=0),M===void 0&&(M=0),p.push({label:Fe(h.getHours())}),_.push({label:$.toFixed(1),title:$.toFixed(2)+" kWh",value:$*10,label2:M.toFixed(1),title2:M.toFixed(2)+" kWh",value2:M*10,color:"#7c3aed",color2:"#37829E"}),l(4,a=Math.max(a,M*10)),l(3,u=Math.max(u,$*10)),dl(h,1)}for(f=0;f{"json"in f&&l(1,n=f.json),"sysinfo"in f&&l(2,i=f.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let f=0,c=[],p=[],_=[];l(4,a=l(3,u=0));let h=new Date,d=new Date;for(dl(h,i.clock_offset-(24+h.getHours()-h.getUTCHours())%24),dl(d,i.clock_offset-(24+d.getHours()-d.getUTCHours())%24),d.setDate(0),f=h.getDate();f<=d.getDate();f++){let $=n["i"+Fe(f)],M=n["e"+Fe(f)];$===void 0&&($=0),M===void 0&&(M=0),p.push({label:Fe(f)}),_.push({label:$.toFixed($<10?1:0),title:$.toFixed(2)+" kWh",value:$,label2:M.toFixed(M<10?1:0),title2:M.toFixed(2)+" kWh",value2:M,color:"#7c3aed",color2:"#37829E"}),l(4,a=Math.max(a,M)),l(3,u=Math.max(u,$))}for(f=1;f{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,f=0,c=[],p=[],_=[];n.s&&n.s.forEach((v,g)=>{var A=v.n?v.n:v.a;f=v.v,f==-127&&(f=0),p.push({label:A.slice(-4)}),_.push({label:f.toFixed(1),value:f,color:"#7c3aed"}),l(3,u=Math.min(u,f)),l(2,o=Math.max(o,f))}),l(2,o=Math.ceil(o)),l(3,u=Math.floor(u));let h=o;u<0&&(h+=Math.abs(u));let d=h/4;for(a=0;a<5;a++)f=u+d*a,c.push({value:f,label:f.toFixed(1)});l(0,i={title:"Temperature sensors (°C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:u,max:o,ticks:c},x:{ticks:p},points:_})}},[i,n,o,u]}class Om extends De{constructor(e){super(),Pe(this,e,Im,Dm,$e,{json:1})}}function Rm(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}let Lm=0;function Fm(t,e,l){let n={},i=0,o;return zc.subscribe(u=>{l(2,o=u)}),Wc(),t.$$.update=()=>{if(t.$$.dirty&6){let u=0,a=[],f=[],c=[];if(a.push({value:0,label:0}),o&&o.p)for(u=0;u0?Fe(p.d)+"."+to[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(u=0;u=i)break;a.push({value:p,label:p})}a.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(a.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:Lm,max:i,ticks:a},x:{ticks:f},points:c})}},[n,i,o]}class qm extends De{constructor(e){super(),Pe(this,e,Fm,Rm,$e,{})}}function Mu(t,e,l){const n=t.slice();return n[18]=e[l],n[20]=l,n}function Tu(t,e,l){const n=t.slice();return n[21]=e[l],n}function Su(t){let e,l,n,i,o,u=t[7],a=[];for(let p=0;pt[14].call(e))},m(c,p){C(c,e,p),s(e,l),s(l,n),s(l,i),s(l,o),s(e,u),f&&f.m(e,null),a=ic(e,t[14].bind(e))},p(c,[p]){p&1024&&X(i,c[10]),c[7]?f?f.p(c,p):(f=Su(c),f.c(),f.m(e,null)):f&&(f.d(1),f=null)},i:_e,o:_e,d(c){c&&y(e),f&&f.d(),a()}}}let Um=12;function jm(t,e,l){let n;Gc.subscribe(E=>{l(11,n=E)});let i,o=0;function u(){n.data.unshift(0),l(11,n.data=n.data.slice(0,n.size),n),o+=10,i=setTimeout(u,1e4)}Lc.subscribe(E=>{o>0?n.data&&E.u-o>=10&&(i&&clearTimeout(i),n.data.unshift(E.i-E.e),l(11,n.data=n.data.slice(0,n.size),n),o+=10,i=setTimeout(u,1e4)):o=E.u});let a,f,c,p,_,h,d,v,g,A,$,M,P;function F(){c=this.clientWidth,p=this.clientHeight,l(0,c),l(1,p)}return t.$$.update=()=>{if(t.$$.dirty&14847&&(l(2,_=parseInt(p)-50),l(3,h=c-35),l(9,M=h/n.size),l(13,f=0),l(12,a=0),n.data)){for(let I in n.data){let D=n.data[I];l(12,a=Math.max(Math.ceil(D/1e3)*1e3,a)),l(13,f=Math.min(Math.ceil(D/1e3)*1e3,f))}l(10,P=a>2500?"kW":"W"),l(7,A=[]);for(let I=f;I2500?(I/1e3).toFixed(1):I});l(8,$=[]);for(let I=f;I0||t[0].e>0}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&2&&(u.sysinfo=i[1]),o&1&&(u.data=i[0].ea),o&1&&(u.currency=i[0].pc),o&1&&(u.hasExport=i[0].om>0||i[0].e>0),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function qu(t){let e,l,n;return l=new qm({}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt h-64")},m(i,o){C(i,e,o),se(l,e,null),n=!0},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Bu(t){let e,l,n;return l=new Hm({}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Uu(t){let e,l,n;return l=new Tm({props:{json:t[2],sysinfo:t[1]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&4&&(u.json=i[2]),o&2&&(u.sysinfo=i[1]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function ju(t){let e,l,n;return l=new Nm({props:{json:t[3],sysinfo:t[1]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&8&&(u.json=i[3]),o&2&&(u.sysinfo=i[1]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Hu(t){let e,l,n;return l=new Pm({props:{json:t[4],sysinfo:t[1]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&16&&(u.json=i[4]),o&2&&(u.sysinfo=i[1]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Wu(t){let e,l,n;return l=new Om({props:{json:t[5]}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o&32&&(u.json=i[5]),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function Wm(t){let e,l=Qe(t[1].ui.i,t[0].i),n,i=Qe(t[1].ui.e,t[0].om||t[0].e>0),o,u=Qe(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),a,f=Qe(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),c,p=Qe(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,h=Qe(t[1].ui.c,t[0].ea),d,v=Qe(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),g,A=Qe(t[1].ui.l),$,M=Qe(t[1].ui.p,t[0].pe&&!Number.isNaN(t[0].p)),P,F=Qe(t[1].ui.d,t[3]),E,I=Qe(t[1].ui.m,t[4]),D,L=Qe(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),ie,H=l&&Du(t),K=i&&Iu(t),G=u&&Ou(t),Y=f&&Ru(t),Q=p&&Lu(t),z=h&&Fu(t),Z=v&&qu(),V=A&&Bu(),j=M&&Uu(t),ee=F&&ju(t),ue=I&&Hu(t),x=L&&Wu(t);return{c(){e=m("div"),H&&H.c(),n=b(),K&&K.c(),o=b(),G&&G.c(),a=b(),Y&&Y.c(),c=b(),Q&&Q.c(),_=b(),z&&z.c(),d=b(),Z&&Z.c(),g=b(),V&&V.c(),$=b(),j&&j.c(),P=b(),ee&&ee.c(),E=b(),ue&&ue.c(),D=b(),x&&x.c(),r(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(W,U){C(W,e,U),H&&H.m(e,null),s(e,n),K&&K.m(e,null),s(e,o),G&&G.m(e,null),s(e,a),Y&&Y.m(e,null),s(e,c),Q&&Q.m(e,null),s(e,_),z&&z.m(e,null),s(e,d),Z&&Z.m(e,null),s(e,g),V&&V.m(e,null),s(e,$),j&&j.m(e,null),s(e,P),ee&&ee.m(e,null),s(e,E),ue&&ue.m(e,null),s(e,D),x&&x.m(e,null),ie=!0},p(W,[U]){U&3&&(l=Qe(W[1].ui.i,W[0].i)),l?H?(H.p(W,U),U&3&&O(H,1)):(H=Du(W),H.c(),O(H,1),H.m(e,n)):H&&(Ie(),B(H,1,1,()=>{H=null}),Oe()),U&3&&(i=Qe(W[1].ui.e,W[0].om||W[0].e>0)),i?K?(K.p(W,U),U&3&&O(K,1)):(K=Iu(W),K.c(),O(K,1),K.m(e,o)):K&&(Ie(),B(K,1,1,()=>{K=null}),Oe()),U&3&&(u=Qe(W[1].ui.v,W[0].u1>100||W[0].u2>100||W[0].u3>100)),u?G?(G.p(W,U),U&3&&O(G,1)):(G=Ou(W),G.c(),O(G,1),G.m(e,a)):G&&(Ie(),B(G,1,1,()=>{G=null}),Oe()),U&3&&(f=Qe(W[1].ui.a,W[0].i1>.01||W[0].i2>.01||W[0].i3>.01)),f?Y?(Y.p(W,U),U&3&&O(Y,1)):(Y=Ru(W),Y.c(),O(Y,1),Y.m(e,c)):Y&&(Ie(),B(Y,1,1,()=>{Y=null}),Oe()),U&3&&(p=Qe(W[1].ui.r,W[0].ri>0||W[0].re>0||W[0].ric>0||W[0].rec>0)),p?Q?(Q.p(W,U),U&3&&O(Q,1)):(Q=Lu(W),Q.c(),O(Q,1),Q.m(e,_)):Q&&(Ie(),B(Q,1,1,()=>{Q=null}),Oe()),U&3&&(h=Qe(W[1].ui.c,W[0].ea)),h?z?(z.p(W,U),U&3&&O(z,1)):(z=Fu(W),z.c(),O(z,1),z.m(e,d)):z&&(Ie(),B(z,1,1,()=>{z=null}),Oe()),U&3&&(v=Qe(W[1].ui.t,W[0].pr&&(W[0].pr.startsWith("10YNO")||W[0].pr=="10Y1001A1001A48H"))),v?Z?U&3&&O(Z,1):(Z=qu(),Z.c(),O(Z,1),Z.m(e,g)):Z&&(Ie(),B(Z,1,1,()=>{Z=null}),Oe()),U&2&&(A=Qe(W[1].ui.l)),A?V?U&2&&O(V,1):(V=Bu(),V.c(),O(V,1),V.m(e,$)):V&&(Ie(),B(V,1,1,()=>{V=null}),Oe()),U&3&&(M=Qe(W[1].ui.p,W[0].pe&&!Number.isNaN(W[0].p))),M?j?(j.p(W,U),U&3&&O(j,1)):(j=Uu(W),j.c(),O(j,1),j.m(e,P)):j&&(Ie(),B(j,1,1,()=>{j=null}),Oe()),U&10&&(F=Qe(W[1].ui.d,W[3])),F?ee?(ee.p(W,U),U&10&&O(ee,1)):(ee=ju(W),ee.c(),O(ee,1),ee.m(e,E)):ee&&(Ie(),B(ee,1,1,()=>{ee=null}),Oe()),U&18&&(I=Qe(W[1].ui.m,W[4])),I?ue?(ue.p(W,U),U&18&&O(ue,1)):(ue=Hu(W),ue.c(),O(ue,1),ue.m(e,D)):ue&&(Ie(),B(ue,1,1,()=>{ue=null}),Oe()),U&35&&(L=Qe(W[1].ui.s,W[0].t&&W[0].t!=-127&&W[5].c>1)),L?x?(x.p(W,U),U&35&&O(x,1)):(x=Wu(W),x.c(),O(x,1),x.m(e,null)):x&&(Ie(),B(x,1,1,()=>{x=null}),Oe())},i(W){ie||(O(H),O(K),O(G),O(Y),O(Q),O(z),O(Z),O(V),O(j),O(ee),O(ue),O(x),ie=!0)},o(W){B(H),B(K),B(G),B(Y),B(Q),B(z),B(Z),B(V),B(j),B(ee),B(ue),B(x),ie=!1},d(W){W&&y(e),H&&H.d(),K&&K.d(),G&&G.d(),Y&&Y.d(),Q&&Q.d(),z&&z.d(),Z&&Z.d(),V&&V.d(),j&&j.d(),ee&&ee.d(),ue&&ue.d(),x&&x.d()}}}function zm(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},u={},a={},f={};return Co.subscribe(c=>{l(2,o=c)}),Bc.subscribe(c=>{l(3,u=c)}),Uc.subscribe(c=>{l(4,a=c)}),Hc.subscribe(c=>{l(5,f=c)}),t.$$set=c=>{"data"in c&&l(0,n=c.data),"sysinfo"in c&&l(1,i=c.sysinfo)},[n,i,o,u,a,f]}class Gm extends De{constructor(e){super(),Pe(this,e,zm,Wm,$e,{data:0,sysinfo:1})}}let uo={};const yi=it(uo);async function Vm(){uo=await(await fetch("/configuration.json")).json(),yi.set(uo)}function zu(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function Km(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=3,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Ym(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=20,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Gu(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Vu(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=b(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){C(i,e,o),C(i,l,o),C(i,n,o)},d(i){i&&y(e),i&&y(l),i&&y(n)}}}function Ku(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Yu(t){let e,l,n;return{c(){e=m("option"),l=S("GPIO"),n=S(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){C(i,e,o),s(e,l),s(e,n)},d(i){i&&y(e)}}}function Qu(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&Yu(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),C(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=Yu(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&y(e)}}}function Qm(t){let e,l,n,i,o;function u(v,g){return v[0]=="esp32c3"?Ym:Km}let a=u(t),f=a(t),c=t[0]=="esp8266"&&Gu(),p=(t[0]=="esp32"||t[0]=="esp32solo")&&Vu(),_=t[0]=="esp32s2"&&Ku(),h={length:t[1]+1},d=[];for(let v=0;v{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{if(t.$$.dirty&1)switch(n){case"esp8266":l(1,i=16);break;case"esp32s2":l(1,i=44);break;case"esp32c3":l(1,i=19);break}},[n,i]}class fo extends De{constructor(e){super(),Pe(this,e,Xm,Qm,$e,{chip:0})}}function Xu(t){let e,l,n=t[1]&&Zu(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),r(l,"class","fixed inset-0 bg-gray-500 dark:bg-gray-900 bg-opacity-50 flex items-center justify-center"),r(e,"class","z-50"),r(e,"aria-modal","true")},m(i,o){C(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=Zu(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&y(e),n&&n.d()}}}function Zu(t){let e,l;return{c(){e=m("div"),l=S(t[1]),r(e,"class","bg-white dark:bg-gray-600 m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 dark:text-white w-96")},m(n,i){C(n,e,i),s(e,l)},p(n,i){i&2&&X(l,n[1])},d(n){n&&y(e)}}}function Zm(t){let e,l=t[0]&&Xu(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),C(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=Xu(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:_e,o:_e,d(n){l&&l.d(n),n&&y(e)}}}function Jm(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class jt extends De{constructor(e){super(),Pe(this,e,Jm,Zm,$e,{active:0,message:1})}}function Ju(t,e,l){const n=t.slice();return n[1]=e[l],n}function xu(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=S("Europe/"),i=S(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,u){C(o,e,u),s(e,l),s(e,i)},p:_e,d(o){o&&y(e)}}}function xm(t){let e,l,n,i=t[0],o=[];for(let u=0;u>1&1,N=0;N0;k--)N[k]=N[k]?N[k-1]^E.EXPONENT[L._modN(E.LOG[N[k]]+T)]:N[k-1];N[0]=E.EXPONENT[L._modN(E.LOG[N[0]]+T)]}for(T=0;T<=w;T++)N[T]=E.LOG[N[T]]},_checkBadness:function(){var T,k,w,N,R,J=0,te=this._badness,fe=this.buffer,de=this.width;for(R=0;Rde*de;)ae-=de*de,Ee++;for(J+=Ee*L.N4,N=0;N=te-2&&(T=te-2,R>9&&T--);var fe=T;if(R>9){for(J[fe+2]=0,J[fe+3]=0;fe--;)k=J[fe],J[fe+3]|=255&k<<4,J[fe+2]=k>>4;J[2]|=255&T<<4,J[1]=T>>4,J[0]=64|T>>12}else{for(J[fe+1]=0,J[fe+2]=0;fe--;)k=J[fe],J[fe+2]|=255&k<<4,J[fe+1]=k>>4;J[1]|=255&T<<4,J[0]=64|T>>4}for(fe=T+3-(R<10);fe=5&&(w+=L.N1+N[k]-5);for(k=3;kT||N[k-3]*3>=N[k]*4||N[k+3]*3>=N[k]*4)&&(w+=L.N3);return w},_finish:function(){this._stringBuffer=this.buffer.slice();var T,k,w=0,N=3e4;for(k=0;k<8&&(this._applyMask(k),T=this._checkBadness(),T>=1)N&1&&(R[J-1-k+J*8]=1,k<6?R[8+J*k]=1:R[8+J*(k+1)]=1);for(k=0;k<7;k++,N>>=1)N&1&&(R[8+J*(J-7+k)]=1,k?R[6-k+J*8]=1:R[7+J*8]=1)},_interleaveBlocks:function(){var T,k,w=this._dataBlock,N=this._ecc,R=this._eccBlock,J=0,te=this._calculateMaxLength(),fe=this._neccBlock1,de=this._neccBlock2,we=this._stringBuffer;for(T=0;T1)for(T=$.BLOCK[N],w=R-7;;){for(k=R-7;k>T-3&&(this._addAlignment(k,w),!(k6)for(T=D.BLOCK[J-7],k=17,w=0;w<6;w++)for(N=0;N<3;N++,k--)1&(k>11?J>>k-12:T>>k)?(R[5-w+te*(2-N+te-11)]=1,R[2-N+te-11+te*(5-w)]=1):(this._setMask(5-w,2-N+te-11),this._setMask(2-N+te-11,5-w))},_isMasked:function(T,k){var w=L._getMaskBit(T,k);return this._mask[w]===1},_pack:function(){var T,k,w,N=1,R=1,J=this.width,te=J-1,fe=J-1,de=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(k=0;kk&&(w=T,T=k,k=w),w=k,w+=k*k,w>>=1,w+=T,w},_modN:function(T){for(;T>=255;)T-=255,T=(T>>8)+(T&255);return T},N1:3,N2:3,N3:40,N4:10}),ie=L,H=d.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var T=this.element;T.width=T.height=this.qrious.size}}),K=H,G=_.extend(function(T,k,w,N){this.name=T,this.modifiable=!!k,this.defaultValue=w,this._valueTransformer=N},{transform:function(T){var k=this._valueTransformer;return typeof k=="function"?k(T,this):T}}),Y=G,Q=_.extend(null,{abs:function(T){return T!=null?Math.abs(T):null},hasOwn:function(T,k){return Object.prototype.hasOwnProperty.call(T,k)},noop:function(){},toUpperCase:function(T){return T!=null?T.toUpperCase():null}}),z=Q,Z=_.extend(function(T){this.options={},T.forEach(function(k){this.options[k.name]=k},this)},{exists:function(T){return this.options[T]!=null},get:function(T,k){return Z._get(this.options[T],k)},getAll:function(T){var k,w=this.options,N={};for(k in w)z.hasOwn(w,k)&&(N[k]=Z._get(w[k],T));return N},init:function(T,k,w){typeof w!="function"&&(w=z.noop);var N,R;for(N in this.options)z.hasOwn(this.options,N)&&(R=this.options[N],Z._set(R,R.defaultValue,k),Z._createAccessor(R,k,w));this._setAll(T,k,!0)},set:function(T,k,w){return this._set(T,k,w)},setAll:function(T,k){return this._setAll(T,k)},_set:function(T,k,w,N){var R=this.options[T];if(!R)throw new Error("Invalid option: "+T);if(!R.modifiable&&!N)throw new Error("Option cannot be modified: "+T);return Z._set(R,k,w)},_setAll:function(T,k,w){if(!T)return!1;var N,R=!1;for(N in T)z.hasOwn(T,N)&&this._set(N,T[N],k,w)&&(R=!0);return R}},{_createAccessor:function(T,k,w){var N={get:function(){return Z._get(T,k)}};T.modifiable&&(N.set=function(R){Z._set(T,R,k)&&w(R,T)}),Object.defineProperty(k,T.name,N)},_get:function(T,k){return k["_"+T.name]},_set:function(T,k,w){var N="_"+T.name,R=w[N],J=T.transform(k??T.defaultValue);return w[N]=J,J!==R}}),V=Z,j=_.extend(function(){this._services={}},{getService:function(T){var k=this._services[T];if(!k)throw new Error("Service is not being managed with name: "+T);return k},setService:function(T,k){if(this._services[T])throw new Error("Service is already managed with name: "+T);k&&(this._services[T]=k)}}),ee=j,ue=new V([new Y("background",!0,"white"),new Y("backgroundAlpha",!0,1,z.abs),new Y("element"),new Y("foreground",!0,"black"),new Y("foregroundAlpha",!0,1,z.abs),new Y("level",!0,"L",z.toUpperCase),new Y("mime",!0,"image/png"),new Y("padding",!0,null,z.abs),new Y("size",!0,100,z.abs),new Y("value",!0,"")]),x=new ee,W=_.extend(function(T){ue.init(T,this,this.update.bind(this));var k=ue.get("element",this),w=x.getService("element"),N=k&&w.isCanvas(k)?k:w.createCanvas(),R=k&&w.isImage(k)?k:w.createImage();this._canvasRenderer=new g(this,N,!0),this._imageRenderer=new K(this,R,R===k),this.update()},{get:function(){return ue.getAll(this)},set:function(T){ue.setAll(T,this)&&this.update()},toDataURL:function(T){return this.canvas.toDataURL(T||this.mime)},update:function(){var T=new ie({level:this.level,value:this.value});this._canvasRenderer.render(T),this._imageRenderer.render(T)}},{use:function(T){x.setService(T.getName(),T)}});Object.defineProperties(W.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var U=W,ke=U,He=_.extend({getName:function(){}}),Be=He,We=Be.extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(T){},isImage:function(T){}}),Ne=We,ge=Ne.extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(T){return T instanceof HTMLCanvasElement},isImage:function(T){return T instanceof HTMLImageElement}}),Re=ge;ke.use(new Re);var Me=ke;return Me})})(Jc);var op=Jc.exports;const rp=sp(op);function ap(t){let e,l;return{c(){e=m("img"),Xs(e.src,l=t[2])||r(e,"src",l),r(e,"alt",t[0]),r(e,"class",t[1])},m(n,i){C(n,e,i)},p(n,[i]){i&4&&!Xs(e.src,l=n[2])&&r(e,"src",l),i&1&&r(e,"alt",n[0]),i&2&&r(e,"class",n[1])},i:_e,o:_e,d(n){n&&y(e)}}}function up(t,e,l){const n=new rp;let{errorCorrection:i="L"}=e,{background:o="#fff"}=e,{color:u="#000"}=e,{size:a="200"}=e,{value:f=""}=e,{padding:c=0}=e,{className:p="qrcode"}=e,_="";function h(){n.set({background:o,foreground:u,level:i,padding:c,size:a,value:f}),l(2,_=n.toDataURL("image/jpeg"))}return sc(()=>{h()}),t.$$set=d=>{"errorCorrection"in d&&l(3,i=d.errorCorrection),"background"in d&&l(4,o=d.background),"color"in d&&l(5,u=d.color),"size"in d&&l(6,a=d.size),"value"in d&&l(0,f=d.value),"padding"in d&&l(7,c=d.padding),"className"in d&&l(1,p=d.className)},t.$$.update=()=>{t.$$.dirty&1&&f&&h()},[f,p,_,i,o,u,a,c]}class fp extends De{constructor(e){super(),Pe(this,e,up,ap,$e,{errorCorrection:3,background:4,color:5,size:6,value:0,padding:7,className:1})}}function ef(t,e,l){const n=t.slice();return n[103]=e[l],n[104]=e,n[105]=l,n}function tf(t,e,l){const n=t.slice();return n[106]=e[l],n[107]=e,n[108]=l,n}function cp(t,e,l){const n=t.slice();return n[109]=e[l],n}function mp(t,e,l){const n=t.slice();return n[112]=e[l],n}function pp(t){let e,l;return{c(){e=m("option"),l=S(t[112]),e.__value=t[112],e.value=e.__value},m(n,i){C(n,e,i),s(e,l)},p:_e,d(n){n&&y(e)}}}function lf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","pt"),r(l,"type","text"),r(l,"class","in-s"),r(l,"placeholder","ENTSO-E API key, optional, read docs")},m(o,u){C(o,e,u),C(o,l,u),ne(l,t[3].p.t),n||(i=le(l,"input",t[22]),n=!0)},p(o,u){u[0]&8&&l.value!==o[3].p.t&&ne(l,o[3].p.t)},d(o){o&&y(e),o&&y(l),n=!1,i()}}}function nf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d;return{c(){e=m("div"),l=S("Username"),n=m("br"),i=b(),o=m("input"),u=b(),a=m("div"),f=S("Password"),c=m("br"),p=b(),_=m("input"),r(o,"name","gu"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(_,"name","gp"),r(_,"type","password"),r(_,"class","in-s"),r(a,"class","my-1")},m(v,g){C(v,e,g),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].g.u),C(v,u,g),C(v,a,g),s(a,f),s(a,c),s(a,p),s(a,_),ne(_,t[3].g.p),h||(d=[le(o,"input",t[24]),le(_,"input",t[25])],h=!0)},p(v,g){g[0]&8&&o.value!==v[3].g.u&&ne(o,v[3].g.u),g[0]&8&&_.value!==v[3].g.p&&ne(_,v[3].g.p)},d(v){v&&y(e),v&&y(u),v&&y(a),h=!1,Ge(d)}}}function _p(t){let e,l=t[109]*100+"",n;return{c(){e=m("option"),n=S(l),e.__value=t[109]*100,e.value=e.__value},m(i,o){C(i,e,o),s(e,n)},p:_e,d(i){i&&y(e)}}}function sf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","mek"),r(l,"type","text"),r(l,"class","in-s")},m(o,u){C(o,e,u),C(o,l,u),ne(l,t[3].m.e.k),n||(i=le(l,"input",t[35]),n=!0)},p(o,u){u[0]&8&&l.value!==o[3].m.e.k&&ne(l,o[3].m.e.k)},d(o){o&&y(e),o&&y(l),n=!1,i()}}}function of(t){let e,l,n,i,o,u,a;return{c(){e=m("div"),l=S("Authentication key"),n=m("br"),i=b(),o=m("input"),r(o,"name","mea"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].m.e.a),u||(a=le(o,"input",t[36]),u=!0)},p(f,c){c[0]&8&&o.value!==f[3].m.e.a&&ne(o,f[3].m.e.a)},d(f){f&&y(e),u=!1,a()}}}function rf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H;return{c(){e=m("div"),l=m("div"),n=S("Watt"),i=m("br"),o=b(),u=m("input"),a=b(),f=m("div"),c=S("Volt"),p=m("br"),_=b(),h=m("input"),d=b(),v=m("div"),g=S("Amp"),A=m("br"),$=b(),M=m("input"),P=b(),F=m("div"),E=S("kWh"),I=m("br"),D=b(),L=m("input"),r(u,"name","mmw"),r(u,"type","number"),r(u,"min","0.00"),r(u,"max","1000"),r(u,"step","0.001"),r(u,"class","in-f tr w-full"),r(l,"class","w-1/4"),r(h,"name","mmv"),r(h,"type","number"),r(h,"min","0.00"),r(h,"max","1000"),r(h,"step","0.001"),r(h,"class","in-m tr w-full"),r(f,"class","w-1/4"),r(M,"name","mma"),r(M,"type","number"),r(M,"min","0.00"),r(M,"max","1000"),r(M,"step","0.001"),r(M,"class","in-m tr w-full"),r(v,"class","w-1/4"),r(L,"name","mmc"),r(L,"type","number"),r(L,"min","0.00"),r(L,"max","1000"),r(L,"step","0.001"),r(L,"class","in-l tr w-full"),r(F,"class","w-1/4"),r(e,"class","flex my-1")},m(K,G){C(K,e,G),s(e,l),s(l,n),s(l,i),s(l,o),s(l,u),ne(u,t[3].m.m.w),s(e,a),s(e,f),s(f,c),s(f,p),s(f,_),s(f,h),ne(h,t[3].m.m.v),s(e,d),s(e,v),s(v,g),s(v,A),s(v,$),s(v,M),ne(M,t[3].m.m.a),s(e,P),s(e,F),s(F,E),s(F,I),s(F,D),s(F,L),ne(L,t[3].m.m.c),ie||(H=[le(u,"input",t[38]),le(h,"input",t[39]),le(M,"input",t[40]),le(L,"input",t[41])],ie=!0)},p(K,G){G[0]&8&&he(u.value)!==K[3].m.m.w&&ne(u,K[3].m.m.w),G[0]&8&&he(h.value)!==K[3].m.m.v&&ne(h,K[3].m.m.v),G[0]&8&&he(M.value)!==K[3].m.m.a&&ne(M,K[3].m.m.a),G[0]&8&&he(L.value)!==K[3].m.m.c&&ne(L,K[3].m.m.c)},d(K){K&&y(e),ie=!1,Ge(H)}}}function af(t){let e;return{c(){e=m("option"),e.textContent="Ethernet",e.__value=3,e.value=e.__value},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function uf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue,x,W;return{c(){e=m("div"),l=S("SSID"),n=m("br"),i=b(),o=m("input"),u=b(),a=m("div"),f=S("Password"),c=m("br"),p=b(),_=m("input"),h=b(),d=m("div"),v=m("div"),g=S("Power saving"),A=m("br"),$=b(),M=m("select"),P=m("option"),P.textContent="Default",F=m("option"),F.textContent="Off",E=m("option"),E.textContent="Minimum",I=m("option"),I.textContent="Maximum",D=b(),L=m("div"),ie=S("Power"),H=m("br"),K=b(),G=m("div"),Y=m("input"),Q=b(),z=m("span"),z.textContent="dBm",Z=b(),V=m("div"),j=m("label"),ee=m("input"),ue=S(" Allow 802.11b legacy rates"),r(o,"name","ws"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(_,"name","wp"),r(_,"type","password"),r(_,"class","in-s"),r(a,"class","my-1"),P.__value=255,P.value=P.__value,F.__value=0,F.value=F.__value,E.__value=1,E.value=E.__value,I.__value=2,I.value=I.__value,r(M,"name","wz"),r(M,"class","in-s"),t[3].w.z===void 0&&Ke(()=>t[45].call(M)),r(v,"class","w-1/2"),r(Y,"name","ww"),r(Y,"type","number"),r(Y,"min","0"),r(Y,"max","20.5"),r(Y,"step","0.5"),r(Y,"class","in-f tr w-full"),r(z,"class","in-post"),r(G,"class","flex"),r(L,"class","ml-2 w-1/2"),r(d,"class","my-1 flex"),r(ee,"type","checkbox"),r(ee,"name","wb"),ee.__value="true",ee.value=ee.__value,r(ee,"class","rounded mb-1"),r(V,"class","my-3")},m(U,ke){C(U,e,ke),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].w.s),C(U,u,ke),C(U,a,ke),s(a,f),s(a,c),s(a,p),s(a,_),ne(_,t[3].w.p),C(U,h,ke),C(U,d,ke),s(d,v),s(v,g),s(v,A),s(v,$),s(v,M),s(M,P),s(M,F),s(M,E),s(M,I),Te(M,t[3].w.z,!0),s(d,D),s(d,L),s(L,ie),s(L,H),s(L,K),s(L,G),s(G,Y),ne(Y,t[3].w.w),s(G,Q),s(G,z),C(U,Z,ke),C(U,V,ke),s(V,j),s(j,ee),ee.checked=t[3].w.b,s(j,ue),x||(W=[le(o,"input",t[43]),le(_,"input",t[44]),le(M,"change",t[45]),le(Y,"input",t[46]),le(ee,"change",t[47])],x=!0)},p(U,ke){ke[0]&8&&o.value!==U[3].w.s&&ne(o,U[3].w.s),ke[0]&8&&_.value!==U[3].w.p&&ne(_,U[3].w.p),ke[0]&8&&Te(M,U[3].w.z),ke[0]&8&&he(Y.value)!==U[3].w.w&&ne(Y,U[3].w.w),ke[0]&8&&(ee.checked=U[3].w.b)},d(U){U&&y(e),U&&y(u),U&&y(a),U&&y(h),U&&y(d),U&&y(Z),U&&y(V),x=!1,Ge(W)}}}function ff(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A;return{c(){e=m("div"),l=S("Gateway"),n=m("br"),i=b(),o=m("input"),u=b(),a=m("div"),f=S("DNS"),c=m("br"),p=b(),_=m("div"),h=m("input"),d=b(),v=m("input"),r(o,"name","ng"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(h,"name","nd1"),r(h,"type","text"),r(h,"class","in-f w-full"),r(v,"name","nd2"),r(v,"type","text"),r(v,"class","in-l w-full"),r(_,"class","flex"),r(a,"class","my-1")},m($,M){C($,e,M),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].n.g),C($,u,M),C($,a,M),s(a,f),s(a,c),s(a,p),s(a,_),s(_,h),ne(h,t[3].n.d1),s(_,d),s(_,v),ne(v,t[3].n.d2),g||(A=[le(o,"input",t[51]),le(h,"input",t[52]),le(v,"input",t[53])],g=!0)},p($,M){M[0]&8&&o.value!==$[3].n.g&&ne(o,$[3].n.g),M[0]&8&&h.value!==$[3].n.d1&&ne(h,$[3].n.d1),M[0]&8&&v.value!==$[3].n.d2&&ne(v,$[3].n.d2)},d($){$&&y(e),$&&y(u),$&&y(a),g=!1,Ge(A)}}}function cf(t){let e,l,n,i,o;return{c(){e=m("label"),l=m("input"),n=S(" SSL"),r(l,"type","checkbox"),r(l,"name","qs"),l.__value="true",l.value=l.__value,r(l,"class","rounded mb-1"),r(e,"class","float-right mr-3")},m(u,a){C(u,e,a),s(e,l),l.checked=t[3].q.s.e,s(e,n),i||(o=[le(l,"change",t[57]),le(l,"change",t[14])],i=!0)},p(u,a){a[0]&8&&(l.checked=u[3].q.s.e)},d(u){u&&y(e),i=!1,Ge(o)}}}function mf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d;const v=[vp,dp],g=[];function A(D,L){return D[3].q.s.c?0:1}n=A(t),i=g[n]=v[n](t);const $=[kp,gp],M=[];function P(D,L){return D[3].q.s.r?0:1}a=P(t),f=M[a]=$[a](t);const F=[Mp,Cp],E=[];function I(D,L){return D[3].q.s.k?0:1}return _=I(t),h=E[_]=F[_](t),{c(){e=m("div"),l=m("span"),i.c(),o=b(),u=m("span"),f.c(),c=b(),p=m("span"),h.c(),r(l,"class","flex pr-2"),r(u,"class","flex pr-2"),r(p,"class","flex pr-2"),r(e,"class","my-1 flex")},m(D,L){C(D,e,L),s(e,l),g[n].m(l,null),s(e,o),s(e,u),M[a].m(u,null),s(e,c),s(e,p),E[_].m(p,null),d=!0},p(D,L){let ie=n;n=A(D),n===ie?g[n].p(D,L):(Ie(),B(g[ie],1,1,()=>{g[ie]=null}),Oe(),i=g[n],i?i.p(D,L):(i=g[n]=v[n](D),i.c()),O(i,1),i.m(l,null));let H=a;a=P(D),a===H?M[a].p(D,L):(Ie(),B(M[H],1,1,()=>{M[H]=null}),Oe(),f=M[a],f?f.p(D,L):(f=M[a]=$[a](D),f.c()),O(f,1),f.m(u,null));let K=_;_=I(D),_===K?E[_].p(D,L):(Ie(),B(E[K],1,1,()=>{E[K]=null}),Oe(),h=E[_],h?h.p(D,L):(h=E[_]=F[_](D),h.c()),O(h,1),h.m(p,null))},i(D){d||(O(i),O(f),O(h),d=!0)},o(D){B(i),B(f),B(h),d=!1},d(D){D&&y(e),g[n].d(),M[a].d(),E[_].d()}}}function dp(t){let e,l;return e=new ol({props:{to:"/mqtt-ca",$$slots:{default:[hp]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i[3]&4194304&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function vp(t){let e,l,n,i,o,u,a,f;return l=new ol({props:{to:"/mqtt-ca",$$slots:{default:[bp]},$$scope:{ctx:t}}}),o=new $o({}),{c(){e=m("span"),re(l.$$.fragment),n=b(),i=m("span"),re(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(c,p){C(c,e,p),se(l,e,null),C(c,n,p),C(c,i,p),se(o,i,null),u=!0,a||(f=[le(i,"click",t[11]),le(i,"keypress",t[11])],a=!0)},p(c,p){const _={};p[3]&4194304&&(_.$$scope={dirty:p,ctx:c}),l.$set(_)},i(c){u||(O(l.$$.fragment,c),O(o.$$.fragment,c),u=!0)},o(c){B(l.$$.fragment,c),B(o.$$.fragment,c),u=!1},d(c){c&&y(e),oe(l),c&&y(n),c&&y(i),oe(o),a=!1,Ge(f)}}}function hp(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload CA",title:"Click here to upload CA"}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p:_e,i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function bp(t){let e;return{c(){e=S("CA OK")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function gp(t){let e,l;return e=new ol({props:{to:"/mqtt-cert",$$slots:{default:[wp]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i[3]&4194304&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function kp(t){let e,l,n,i,o,u,a,f;return l=new ol({props:{to:"/mqtt-cert",$$slots:{default:[yp]},$$scope:{ctx:t}}}),o=new $o({}),{c(){e=m("span"),re(l.$$.fragment),n=b(),i=m("span"),re(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(c,p){C(c,e,p),se(l,e,null),C(c,n,p),C(c,i,p),se(o,i,null),u=!0,a||(f=[le(i,"click",t[12]),le(i,"keypress",t[12])],a=!0)},p(c,p){const _={};p[3]&4194304&&(_.$$scope={dirty:p,ctx:c}),l.$set(_)},i(c){u||(O(l.$$.fragment,c),O(o.$$.fragment,c),u=!0)},o(c){B(l.$$.fragment,c),B(o.$$.fragment,c),u=!1},d(c){c&&y(e),oe(l),c&&y(n),c&&y(i),oe(o),a=!1,Ge(f)}}}function wp(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p:_e,i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function yp(t){let e;return{c(){e=S("Cert OK")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function Cp(t){let e,l;return e=new ol({props:{to:"/mqtt-key",$$slots:{default:[Tp]},$$scope:{ctx:t}}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p(n,i){const o={};i[3]&4194304&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function Mp(t){let e,l,n,i,o,u,a,f;return l=new ol({props:{to:"/mqtt-key",$$slots:{default:[Sp]},$$scope:{ctx:t}}}),o=new $o({}),{c(){e=m("span"),re(l.$$.fragment),n=b(),i=m("span"),re(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(c,p){C(c,e,p),se(l,e,null),C(c,n,p),C(c,i,p),se(o,i,null),u=!0,a||(f=[le(i,"click",t[13]),le(i,"keypress",t[13])],a=!0)},p(c,p){const _={};p[3]&4194304&&(_.$$scope={dirty:p,ctx:c}),l.$set(_)},i(c){u||(O(l.$$.fragment,c),O(o.$$.fragment,c),u=!0)},o(c){B(l.$$.fragment,c),B(o.$$.fragment,c),u=!1},d(c){c&&y(e),oe(l),c&&y(n),c&&y(i),oe(o),a=!1,Ge(f)}}}function Tp(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){re(e.$$.fragment)},m(n,i){se(e,n,i),l=!0},p:_e,i(n){l||(O(e.$$.fragment,n),l=!0)},o(n){B(e.$$.fragment,n),l=!1},d(n){oe(e,n)}}}function Sp(t){let e;return{c(){e=S("Key OK")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function pf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z;return o=new Bt({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=b(),i=m("a"),re(o.$$.fragment),u=b(),a=m("input"),f=b(),c=m("div"),p=m("div"),_=S("Electricity IDX"),h=m("br"),d=b(),v=m("input"),g=b(),A=m("div"),$=S("Current IDX"),M=m("br"),P=b(),F=m("input"),E=b(),I=m("div"),D=S(`Voltage IDX: L1, L2 & L3 `),L=m("div"),ie=m("input"),H=b(),K=m("input"),G=b(),Y=m("input"),r(l,"class","text-sm"),r(i,"href",Ut("MQTT-configuration#domoticz")),r(i,"target","_blank"),r(i,"class","float-right"),r(a,"type","hidden"),r(a,"name","o"),a.value="true",r(v,"name","oe"),r(v,"type","text"),r(v,"class","in-f tr w-full"),r(p,"class","w-1/2"),r(F,"name","oc"),r(F,"type","text"),r(F,"class","in-l tr w-full"),r(A,"class","w-1/2"),r(c,"class","my-1 flex"),r(ie,"name","ou1"),r(ie,"type","text"),r(ie,"class","in-f tr w-1/3"),r(K,"name","ou2"),r(K,"type","text"),r(K,"class","in-m tr w-1/3"),r(Y,"name","ou3"),r(Y,"type","text"),r(Y,"class","in-l tr w-1/3"),r(L,"class","flex"),r(I,"class","my-1"),r(e,"class","cnt")},m(V,j){C(V,e,j),s(e,l),s(e,n),s(e,i),se(o,i,null),s(e,u),s(e,a),s(e,f),s(e,c),s(c,p),s(p,_),s(p,h),s(p,d),s(p,v),ne(v,t[3].o.e),s(c,g),s(c,A),s(A,$),s(A,M),s(A,P),s(A,F),ne(F,t[3].o.c),s(e,E),s(e,I),s(I,D),s(I,L),s(L,ie),ne(ie,t[3].o.u1),s(L,H),s(L,K),ne(K,t[3].o.u2),s(L,G),s(L,Y),ne(Y,t[3].o.u3),Q=!0,z||(Z=[le(v,"input",t[65]),le(F,"input",t[66]),le(ie,"input",t[67]),le(K,"input",t[68]),le(Y,"input",t[69])],z=!0)},p(V,j){j[0]&8&&v.value!==V[3].o.e&&ne(v,V[3].o.e),j[0]&8&&F.value!==V[3].o.c&&ne(F,V[3].o.c),j[0]&8&&ie.value!==V[3].o.u1&&ne(ie,V[3].o.u1),j[0]&8&&K.value!==V[3].o.u2&&ne(K,V[3].o.u2),j[0]&8&&Y.value!==V[3].o.u3&&ne(Y,V[3].o.u3)},i(V){Q||(O(o.$$.fragment,V),Q=!0)},o(V){B(o.$$.fragment,V),Q=!1},d(V){V&&y(e),oe(o),z=!1,Ge(Z)}}}function _f(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y;return o=new Bt({}),{c(){e=m("div"),l=m("strong"),l.textContent="Home-Assistant",n=b(),i=m("a"),re(o.$$.fragment),u=b(),a=m("input"),f=b(),c=m("div"),p=S("Discovery topic prefix"),_=m("br"),h=b(),d=m("input"),v=b(),g=m("div"),A=S("Hostname for URL"),$=m("br"),M=b(),P=m("input"),E=b(),I=m("div"),D=S("Name tag"),L=m("br"),ie=b(),H=m("input"),r(l,"class","text-sm"),r(i,"href",Ut("MQTT-configuration#home-assistant")),r(i,"target","_blank"),r(i,"class","float-right"),r(a,"type","hidden"),r(a,"name","h"),a.value="true",r(d,"name","ht"),r(d,"type","text"),r(d,"class","in-s"),r(d,"placeholder","homeassistant"),r(c,"class","my-1"),r(P,"name","hh"),r(P,"type","text"),r(P,"class","in-s"),r(P,"placeholder",F=t[3].g.h+".local"),r(g,"class","my-1"),r(H,"name","hn"),r(H,"type","text"),r(H,"class","in-s"),r(I,"class","my-1"),r(e,"class","cnt")},m(Q,z){C(Q,e,z),s(e,l),s(e,n),s(e,i),se(o,i,null),s(e,u),s(e,a),s(e,f),s(e,c),s(c,p),s(c,_),s(c,h),s(c,d),ne(d,t[3].h.t),s(e,v),s(e,g),s(g,A),s(g,$),s(g,M),s(g,P),ne(P,t[3].h.h),s(e,E),s(e,I),s(I,D),s(I,L),s(I,ie),s(I,H),ne(H,t[3].h.n),K=!0,G||(Y=[le(d,"input",t[70]),le(P,"input",t[71]),le(H,"input",t[72])],G=!0)},p(Q,z){z[0]&8&&d.value!==Q[3].h.t&&ne(d,Q[3].h.t),(!K||z[0]&8&&F!==(F=Q[3].g.h+".local"))&&r(P,"placeholder",F),z[0]&8&&P.value!==Q[3].h.h&&ne(P,Q[3].h.h),z[0]&8&&H.value!==Q[3].h.n&&ne(H,Q[3].h.n)},i(Q){K||(O(o.$$.fragment,Q),K=!0)},o(Q){B(o.$$.fragment,Q),K=!1},d(Q){Q&&y(e),oe(o),G=!1,Ge(Y)}}}function df(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue;o=new Bt({});let x=t[3].c.es&&vf(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Cloud connections",n=b(),i=m("a"),re(o.$$.fragment),u=b(),a=m("input"),f=b(),c=m("div"),p=m("label"),_=m("input"),h=S(" Enable cloud upload"),d=b(),v=m("div"),g=S("Client ID"),A=m("br"),$=b(),M=m("input"),E=b(),I=m("div"),D=S("Client secret"),L=m("br"),ie=b(),H=m("input"),G=b(),Y=m("div"),Q=m("label"),z=m("input"),Z=S(" Energy Speedometer"),V=b(),x&&x.c(),r(l,"class","text-sm"),r(i,"href",Ut("Cloud")),r(i,"target","_blank"),r(i,"class","float-right"),r(a,"type","hidden"),r(a,"name","c"),a.value="true",r(_,"type","checkbox"),r(_,"name","ce"),_.__value="true",_.value=_.__value,r(_,"class","rounded mb-1"),r(c,"class","my-1"),r(M,"name","ci"),r(M,"type","text"),r(M,"class","in-s"),r(M,"pattern",P=t[3].c.e?"[A-Z0-9]{16}":".*"),M.required=F=t[3].c.e,r(v,"class","my-1"),r(H,"name","cs"),r(H,"type","text"),r(H,"class","in-s"),r(H,"pattern",K=t[3].c.e&&t[3].c.s!="***"?"[A-Z0-9]{16}":".*"),r(I,"class","my-1"),r(z,"type","checkbox"),r(z,"class","rounded mb-1"),r(z,"name","ces"),z.__value="true",z.value=z.__value,r(Y,"class","my-1"),r(e,"class","cnt")},m(W,U){C(W,e,U),s(e,l),s(e,n),s(e,i),se(o,i,null),s(e,u),s(e,a),s(e,f),s(e,c),s(c,p),s(p,_),_.checked=t[3].c.e,s(p,h),s(e,d),s(e,v),s(v,g),s(v,A),s(v,$),s(v,M),ne(M,t[3].c.i),s(e,E),s(e,I),s(I,D),s(I,L),s(I,ie),s(I,H),ne(H,t[3].c.s),s(e,G),s(e,Y),s(Y,Q),s(Q,z),z.checked=t[3].c.es,s(Q,Z),s(Y,V),x&&x.m(Y,null),j=!0,ee||(ue=[le(_,"change",t[73]),le(M,"input",t[74]),le(H,"input",t[75]),le(z,"change",t[76])],ee=!0)},p(W,U){U[0]&8&&(_.checked=W[3].c.e),(!j||U[0]&8&&P!==(P=W[3].c.e?"[A-Z0-9]{16}":".*"))&&r(M,"pattern",P),(!j||U[0]&8&&F!==(F=W[3].c.e))&&(M.required=F),U[0]&8&&M.value!==W[3].c.i&&ne(M,W[3].c.i),(!j||U[0]&8&&K!==(K=W[3].c.e&&W[3].c.s!="***"?"[A-Z0-9]{16}":".*"))&&r(H,"pattern",K),U[0]&8&&H.value!==W[3].c.s&&ne(H,W[3].c.s),U[0]&8&&(z.checked=W[3].c.es),W[3].c.es?x?(x.p(W,U),U[0]&8&&O(x,1)):(x=vf(W),x.c(),O(x,1),x.m(Y,null)):x&&(Ie(),B(x,1,1,()=>{x=null}),Oe())},i(W){j||(O(o.$$.fragment,W),O(x),j=!0)},o(W){B(o.$$.fragment,W),B(x),j=!1},d(W){W&&y(e),oe(o),x&&x.d(),ee=!1,Ge(ue)}}}function vf(t){let e,l,n=t[0].mac+"",i,o,u,a,f=(t[0].meter.id?t[0].meter.id:"missing, required")+"",c,p,_,h,d=t[0].mac&&t[0].meter.id&&hf(t);return{c(){e=m("div"),l=S("MAC: "),i=S(n),o=b(),u=m("div"),a=S("Meter ID: "),c=S(f),p=b(),d&&d.c(),_=Ve(),r(e,"class","pl-5"),r(u,"class","pl-5")},m(v,g){C(v,e,g),s(e,l),s(e,i),C(v,o,g),C(v,u,g),s(u,a),s(u,c),C(v,p,g),d&&d.m(v,g),C(v,_,g),h=!0},p(v,g){(!h||g[0]&1)&&n!==(n=v[0].mac+"")&&X(i,n),(!h||g[0]&1)&&f!==(f=(v[0].meter.id?v[0].meter.id:"missing, required")+"")&&X(c,f),v[0].mac&&v[0].meter.id?d?(d.p(v,g),g[0]&1&&O(d,1)):(d=hf(v),d.c(),O(d,1),d.m(_.parentNode,_)):d&&(Ie(),B(d,1,1,()=>{d=null}),Oe())},i(v){h||(O(d),h=!0)},o(v){B(d),h=!1},d(v){v&&y(e),v&&y(o),v&&y(u),v&&y(p),d&&d.d(v),v&&y(_)}}}function hf(t){let e,l,n;return l=new fp({props:{value:'{"mac":"'+t[0].mac+'","meter":"'+t[0].meter.id+'"}'}}),{c(){e=m("div"),re(l.$$.fragment),r(e,"class","pl-2")},m(i,o){C(i,e,o),se(l,e,null),n=!0},p(i,o){const u={};o[0]&1&&(u.value='{"mac":"'+i[0].mac+'","meter":"'+i[0].meter.id+'"}'),l.$set(u)},i(i){n||(O(l.$$.fragment,i),n=!0)},o(i){B(l.$$.fragment,i),n=!1},d(i){i&&y(e),oe(l)}}}function bf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P;o=new Bt({});let F={length:9},E=[];for(let I=0;I20&&yf(t),_=t[3].i.d.d>0&&Tf(t),h=t[0].chip=="esp8266"&&Sf(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=b(),i=m("a"),re(o.$$.fragment),u=b(),p&&p.c(),a=b(),_&&_.c(),f=b(),h&&h.c(),r(l,"class","text-sm"),r(i,"href",Ut("GPIO-configuration")),r(i,"target","_blank"),r(i,"class","float-right"),r(e,"class","cnt")},m(d,v){C(d,e,v),s(e,l),s(e,n),s(e,i),se(o,i,null),s(e,u),p&&p.m(e,null),s(e,a),_&&_.m(e,null),s(e,f),h&&h.m(e,null),c=!0},p(d,v){d[0].board>20?p?(p.p(d,v),v[0]&1&&O(p,1)):(p=yf(d),p.c(),O(p,1),p.m(e,a)):p&&(Ie(),B(p,1,1,()=>{p=null}),Oe()),d[3].i.d.d>0?_?_.p(d,v):(_=Tf(d),_.c(),_.m(e,f)):_&&(_.d(1),_=null),d[0].chip=="esp8266"?h?h.p(d,v):(h=Sf(d),h.c(),h.m(e,null)):h&&(h.d(1),h=null)},i(d){c||(O(o.$$.fragment,d),O(p),c=!0)},o(d){B(o.$$.fragment,d),B(p),c=!1},d(d){d&&y(e),oe(o),p&&p.d(),_&&_.d(),h&&h.d()}}}function yf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue,x,W,U,ke,He,Be,We,Ne,ge,Re,Me,T,k,w,N,R,J,te,fe,de,we,Ee,ae,Ce,Je,Et,st,ht,lt,At,Ye,Qt,Ht,bt,ze,xe,Xe,Ue,qe,et;c=new fo({props:{chip:t[0].chip}}),A=new fo({props:{chip:t[0].chip}});let Ae=t[0].chip!="esp8266"&&Cf(t),Le=t[3].i.v.p>0&&Mf(t);return{c(){e=m("input"),l=b(),n=m("div"),i=m("div"),o=S("HAN RX"),u=m("br"),a=b(),f=m("select"),re(c.$$.fragment),p=b(),_=m("div"),h=S("HAN TX"),d=m("br"),v=b(),g=m("select"),re(A.$$.fragment),$=b(),M=m("div"),P=m("label"),F=m("input"),E=S(" pullup"),I=b(),D=m("div"),L=m("div"),ie=S("AP button"),H=m("br"),K=b(),G=m("input"),Y=b(),Q=m("div"),z=S("LED"),Z=m("br"),V=b(),j=m("div"),ee=m("input"),ue=b(),x=m("div"),W=m("label"),U=m("input"),ke=S(" inverted"),He=b(),Be=m("div"),We=S("RGB"),Ne=m("label"),ge=m("input"),Re=S(" inverted"),Me=m("br"),T=b(),k=m("div"),w=m("input"),N=b(),R=m("input"),J=b(),te=m("input"),fe=b(),de=m("div"),we=m("div"),Ee=S(`LED dis. GPIO `),ae=m("input"),Ce=b(),Je=m("div"),Et=S("Temperature"),st=m("br"),ht=b(),lt=m("input"),At=b(),Ye=m("div"),Qt=S("Analog temp"),Ht=m("br"),bt=b(),ze=m("input"),xe=b(),Ae&&Ae.c(),Xe=b(),Le&&Le.c(),r(e,"type","hidden"),r(e,"name","i"),e.value="true",r(f,"name","ihp"),r(f,"class","in-f w-full"),t[3].i.h.p===void 0&&Ke(()=>t[80].call(f)),r(i,"class","w-1/3"),r(g,"name","iht"),r(g,"class","in-l w-full"),t[3].i.h.t===void 0&&Ke(()=>t[81].call(g)),r(_,"class","w-1/3"),r(F,"name","ihu"),F.__value="true",F.value=F.__value,r(F,"type","checkbox"),r(F,"class","rounded mb-1"),r(P,"class","ml-2"),r(M,"class","w-1/3"),r(n,"class","flex flex-wrap"),r(G,"name","ia"),r(G,"type","number"),r(G,"min","0"),r(G,"max",t[6]),r(G,"class","in-f tr w-full"),r(L,"class","w-1/3"),r(ee,"name","ilp"),r(ee,"type","number"),r(ee,"min","0"),r(ee,"max",t[6]),r(ee,"class","in-l tr w-full"),r(j,"class","flex"),r(Q,"class","w-1/3"),r(U,"name","ili"),U.__value="true",U.value=U.__value,r(U,"type","checkbox"),r(U,"class","rounded mb-1"),r(W,"class","ml-4"),r(x,"class","w-1/3"),r(ge,"name","iri"),ge.__value="true",ge.value=ge.__value,r(ge,"type","checkbox"),r(ge,"class","rounded mb-1"),r(Ne,"class","ml-4"),r(w,"name","irr"),r(w,"type","number"),r(w,"min","0"),r(w,"max",t[6]),r(w,"class","in-f tr w-1/3"),r(R,"name","irg"),r(R,"type","number"),r(R,"min","0"),r(R,"max",t[6]),r(R,"class","in-m tr w-1/3"),r(te,"name","irb"),r(te,"type","number"),r(te,"min","0"),r(te,"max",t[6]),r(te,"class","in-l tr w-1/3"),r(k,"class","flex"),r(Be,"class","w-full"),r(ae,"name","idd"),r(ae,"type","number"),r(ae,"min","0"),r(ae,"max",t[6]),r(ae,"class","in-s tr"),r(we,"class","my-1 pr-1 w-1/3"),r(de,"class","w-full"),r(lt,"name","itd"),r(lt,"type","number"),r(lt,"min","0"),r(lt,"max",t[6]),r(lt,"class","in-f tr w-full"),r(Je,"class","my-1 w-1/3"),r(ze,"name","ita"),r(ze,"type","number"),r(ze,"min","0"),r(ze,"max",t[6]),r(ze,"class","in-l tr w-full"),r(Ye,"class","my-1 pr-1 w-1/3"),r(D,"class","flex flex-wrap")},m(pe,ce){C(pe,e,ce),C(pe,l,ce),C(pe,n,ce),s(n,i),s(i,o),s(i,u),s(i,a),s(i,f),se(c,f,null),Te(f,t[3].i.h.p,!0),s(n,p),s(n,_),s(_,h),s(_,d),s(_,v),s(_,g),se(A,g,null),Te(g,t[3].i.h.t,!0),s(n,$),s(n,M),s(M,P),s(P,F),F.checked=t[3].i.h.u,s(P,E),C(pe,I,ce),C(pe,D,ce),s(D,L),s(L,ie),s(L,H),s(L,K),s(L,G),ne(G,t[3].i.a),s(D,Y),s(D,Q),s(Q,z),s(Q,Z),s(Q,V),s(Q,j),s(j,ee),ne(ee,t[3].i.l.p),s(D,ue),s(D,x),s(x,W),s(W,U),U.checked=t[3].i.l.i,s(W,ke),s(D,He),s(D,Be),s(Be,We),s(Be,Ne),s(Ne,ge),ge.checked=t[3].i.r.i,s(Ne,Re),s(Be,Me),s(Be,T),s(Be,k),s(k,w),ne(w,t[3].i.r.r),s(k,N),s(k,R),ne(R,t[3].i.r.g),s(k,J),s(k,te),ne(te,t[3].i.r.b),s(D,fe),s(D,de),s(de,we),s(we,Ee),s(we,ae),ne(ae,t[3].i.d.d),s(D,Ce),s(D,Je),s(Je,Et),s(Je,st),s(Je,ht),s(Je,lt),ne(lt,t[3].i.t.d),s(D,At),s(D,Ye),s(Ye,Qt),s(Ye,Ht),s(Ye,bt),s(Ye,ze),ne(ze,t[3].i.t.a),s(D,xe),Ae&&Ae.m(D,null),s(D,Xe),Le&&Le.m(D,null),Ue=!0,qe||(et=[le(f,"change",t[80]),le(g,"change",t[81]),le(F,"change",t[82]),le(G,"input",t[83]),le(ee,"input",t[84]),le(U,"change",t[85]),le(ge,"change",t[86]),le(w,"input",t[87]),le(R,"input",t[88]),le(te,"input",t[89]),le(ae,"input",t[90]),le(lt,"input",t[91]),le(ze,"input",t[92])],qe=!0)},p(pe,ce){const ye={};ce[0]&1&&(ye.chip=pe[0].chip),c.$set(ye),ce[0]&8&&Te(f,pe[3].i.h.p);const zl={};ce[0]&1&&(zl.chip=pe[0].chip),A.$set(zl),ce[0]&8&&Te(g,pe[3].i.h.t),ce[0]&8&&(F.checked=pe[3].i.h.u),(!Ue||ce[0]&64)&&r(G,"max",pe[6]),ce[0]&8&&he(G.value)!==pe[3].i.a&&ne(G,pe[3].i.a),(!Ue||ce[0]&64)&&r(ee,"max",pe[6]),ce[0]&8&&he(ee.value)!==pe[3].i.l.p&&ne(ee,pe[3].i.l.p),ce[0]&8&&(U.checked=pe[3].i.l.i),ce[0]&8&&(ge.checked=pe[3].i.r.i),(!Ue||ce[0]&64)&&r(w,"max",pe[6]),ce[0]&8&&he(w.value)!==pe[3].i.r.r&&ne(w,pe[3].i.r.r),(!Ue||ce[0]&64)&&r(R,"max",pe[6]),ce[0]&8&&he(R.value)!==pe[3].i.r.g&&ne(R,pe[3].i.r.g),(!Ue||ce[0]&64)&&r(te,"max",pe[6]),ce[0]&8&&he(te.value)!==pe[3].i.r.b&&ne(te,pe[3].i.r.b),(!Ue||ce[0]&64)&&r(ae,"max",pe[6]),ce[0]&8&&he(ae.value)!==pe[3].i.d.d&&ne(ae,pe[3].i.d.d),(!Ue||ce[0]&64)&&r(lt,"max",pe[6]),ce[0]&8&&he(lt.value)!==pe[3].i.t.d&&ne(lt,pe[3].i.t.d),(!Ue||ce[0]&64)&&r(ze,"max",pe[6]),ce[0]&8&&he(ze.value)!==pe[3].i.t.a&&ne(ze,pe[3].i.t.a),pe[0].chip!="esp8266"?Ae?Ae.p(pe,ce):(Ae=Cf(pe),Ae.c(),Ae.m(D,Xe)):Ae&&(Ae.d(1),Ae=null),pe[3].i.v.p>0?Le?Le.p(pe,ce):(Le=Mf(pe),Le.c(),Le.m(D,null)):Le&&(Le.d(1),Le=null)},i(pe){Ue||(O(c.$$.fragment,pe),O(A.$$.fragment,pe),Ue=!0)},o(pe){B(c.$$.fragment,pe),B(A.$$.fragment,pe),Ue=!1},d(pe){pe&&y(e),pe&&y(l),pe&&y(n),oe(c),oe(A),pe&&y(I),pe&&y(D),Ae&&Ae.d(),Le&&Le.d(),qe=!1,Ge(et)}}}function Cf(t){let e,l,n,i,o,u,a;return{c(){e=m("div"),l=S("Vcc"),n=m("br"),i=b(),o=m("input"),r(o,"name","ivp"),r(o,"type","number"),r(o,"min","0"),r(o,"max",t[6]),r(o,"class","in-s tr w-full"),r(e,"class","my-1 pl-1 w-1/3")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].i.v.p),u||(a=le(o,"input",t[93]),u=!0)},p(f,c){c[0]&64&&r(o,"max",f[6]),c[0]&8&&he(o.value)!==f[3].i.v.p&&ne(o,f[3].i.v.p)},d(f){f&&y(e),u=!1,a()}}}function Mf(t){let e,l,n,i,o,u,a,f,c,p;return{c(){e=m("div"),l=S("Voltage divider"),n=m("br"),i=b(),o=m("div"),u=m("input"),a=b(),f=m("input"),r(u,"name","ivdv"),r(u,"type","number"),r(u,"min","0"),r(u,"max","65535"),r(u,"class","in-f tr w-full"),r(u,"placeholder","VCC"),r(f,"name","ivdg"),r(f,"type","number"),r(f,"min","0"),r(f,"max","65535"),r(f,"class","in-l tr w-full"),r(f,"placeholder","GND"),r(o,"class","flex"),r(e,"class","my-1")},m(_,h){C(_,e,h),s(e,l),s(e,n),s(e,i),s(e,o),s(o,u),ne(u,t[3].i.v.d.v),s(o,a),s(o,f),ne(f,t[3].i.v.d.g),c||(p=[le(u,"input",t[94]),le(f,"input",t[95])],c=!0)},p(_,h){h[0]&8&&he(u.value)!==_[3].i.v.d.v&&ne(u,_[3].i.v.d.v),h[0]&8&&he(f.value)!==_[3].i.v.d.g&&ne(f,_[3].i.v.d.g)},d(_){_&&y(e),c=!1,Ge(p)}}}function Tf(t){let e,l,n,i,o,u,a;return{c(){e=m("div"),l=S(`LED behaviour `),n=m("select"),i=m("option"),i.textContent="Enabled",o=m("option"),o.textContent="Disabled",i.__value=0,i.value=i.__value,o.__value=1,o.value=o.__value,r(n,"name","idb"),r(n,"class","in-s"),t[3].i.d.b===void 0&&Ke(()=>t[96].call(n)),r(e,"class","my-1 w-full")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(n,i),s(n,o),Te(n,t[3].i.d.b,!0),u||(a=le(n,"change",t[96]),u=!0)},p(f,c){c[0]&8&&Te(n,f[3].i.d.b)},d(f){f&&y(e),u=!1,a()}}}function Sf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M=(t[0].board==2||t[0].board==100)&&$f(t);return{c(){e=m("input"),l=b(),n=m("div"),i=m("div"),o=S("Vcc offset"),u=m("br"),a=b(),f=m("input"),c=b(),p=m("div"),_=S("Multiplier"),h=m("br"),d=b(),v=m("input"),g=b(),M&&M.c(),r(e,"type","hidden"),r(e,"name","iv"),e.value="true",r(f,"name","ivo"),r(f,"type","number"),r(f,"min","0.0"),r(f,"max","3.5"),r(f,"step","0.01"),r(f,"class","in-f tr w-full"),r(i,"class","w-1/3"),r(v,"name","ivm"),r(v,"type","number"),r(v,"min","0.1"),r(v,"max","10"),r(v,"step","0.01"),r(v,"class","in-l tr w-full"),r(p,"class","w-1/3 pr-1"),r(n,"class","my-1 flex flex-wrap")},m(P,F){C(P,e,F),C(P,l,F),C(P,n,F),s(n,i),s(i,o),s(i,u),s(i,a),s(i,f),ne(f,t[3].i.v.o),s(n,c),s(n,p),s(p,_),s(p,h),s(p,d),s(p,v),ne(v,t[3].i.v.m),s(n,g),M&&M.m(n,null),A||($=[le(f,"input",t[97]),le(v,"input",t[98])],A=!0)},p(P,F){F[0]&8&&he(f.value)!==P[3].i.v.o&&ne(f,P[3].i.v.o),F[0]&8&&he(v.value)!==P[3].i.v.m&&ne(v,P[3].i.v.m),P[0].board==2||P[0].board==100?M?M.p(P,F):(M=$f(P),M.c(),M.m(n,null)):M&&(M.d(1),M=null)},d(P){P&&y(e),P&&y(l),P&&y(n),M&&M.d(),A=!1,Ge($)}}}function $f(t){let e,l,n,i,o,u,a;return{c(){e=m("div"),l=S("Boot limit"),n=m("br"),i=b(),o=m("input"),r(o,"name","ivb"),r(o,"type","number"),r(o,"min","2.5"),r(o,"max","3.5"),r(o,"step","0.1"),r(o,"class","in-s tr w-full"),r(e,"class","w-1/3 pl-1")},m(f,c){C(f,e,c),s(e,l),s(e,n),s(e,i),s(e,o),ne(o,t[3].i.v.b),u||(a=le(o,"input",t[99]),u=!0)},p(f,c){c[0]&8&&he(o.value)!==f[3].i.v.b&&ne(o,f[3].i.v.b)},d(f){f&&y(e),u=!1,a()}}}function Nf(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$=t[3].d.t&&Ef();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=b(),n=m("div"),i=m("label"),o=m("input"),u=S(" Enable telnet"),a=b(),$&&$.c(),f=b(),c=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",h=m("option"),h.textContent="Debug",d=m("option"),d.textContent="Info",v=m("option"),v.textContent="Warning",r(e,"class","bd-red"),r(o,"type","checkbox"),r(o,"name","dt"),o.__value="true",o.value=o.__value,r(o,"class","rounded mb-1"),r(n,"class","my-1"),_.__value=1,_.value=_.__value,h.__value=2,h.value=h.__value,d.__value=3,d.value=d.__value,v.__value=4,v.value=v.__value,r(p,"name","dl"),r(p,"class","in-s"),t[3].d.l===void 0&&Ke(()=>t[102].call(p)),r(c,"class","my-1")},m(M,P){C(M,e,P),C(M,l,P),C(M,n,P),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,u),C(M,a,P),$&&$.m(M,P),C(M,f,P),C(M,c,P),s(c,p),s(p,_),s(p,h),s(p,d),s(p,v),Te(p,t[3].d.l,!0),g||(A=[le(o,"change",t[101]),le(p,"change",t[102])],g=!0)},p(M,P){P[0]&8&&(o.checked=M[3].d.t),M[3].d.t?$||($=Ef(),$.c(),$.m(f.parentNode,f)):$&&($.d(1),$=null),P[0]&8&&Te(p,M[3].d.l)},d(M){M&&y(e),M&&y(l),M&&y(n),M&&y(a),$&&$.d(M),M&&y(f),M&&y(c),g=!1,Ge(A)}}}function Ef(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",r(e,"class","bd-red")},m(l,n){C(l,e,n)},d(l){l&&y(e)}}}function $p(t){let e,l,n,i,o,u,a,f,c,p,_,h,d,v,g,A,$,M,P,F,E,I,D,L,ie,H,K,G,Y,Q,z,Z,V,j,ee,ue,x,W,U,ke,He,Be,We,Ne,ge,Re,Me,T,k,w,N,R,J,te,fe,de,we,Ee,ae,Ce,Je,Et,st,ht,lt,At,Ye,Qt,Ht,bt,ze,xe,Xe,Ue,qe,et,Ae,Le,pe,ce,ye,zl,hl,_n,Pt,Ai,Pi,Di,bl,Ii,Oi,Ri,Dt,Nl,El,Al,Li,Fi,je,dn,qi,Pl,Dl,Bi,Gl,Ze,mt,Vl,Il,Ui,Ol,ji,Wt,vn,hn,Eo,rl,Hi,Ao,Ss,Po,fi,Xt,Do,Io,Rl,al,Ll,Oo,Wi,Ro,dt,Fl,Lo,zi,bn,gn,kn,wn,Gi,Fo,It,Vi,qo,Kl,Bo,Uo,jo,ul,yn,Cn,Ho,Mn,Yl,Wo,zo,Go,Tn,Zt,Vo,Ki,Ko,Ql,Yo,Qo,Xo,Sn,Jt,Zo,Yi,Jo,$s,xo,Xl,Qi,xt,er,tr,lr,Ns,Xi,el,nr,ir,sr,Ot,Zi,or,$n,Nn,rr,ci,ar,Zl,ur,fr,cr,zt,En,An,mr,pr,pt,Ji,_r,Pn,Dn,dr,Jl,vr,hr,br,ql,fl,In,On,gr,Rt,xi,es,kr,Lt,Rn,ts,ls,wr,Es,ns,is,tl,yr,Cr,mi,Mr,Bl,Tr,pi,ll,Sr,$r,Nr,ss,gl,Er,tt,os,Ar,Ln,Fn,Pr,_i,Dr,cl,Ir,As,Or,Rr,qn,kl,Lr,nl,Fr,Ps,xl,qr,Br,Ur,wl,jr,en,Hr,Wr,zr,yl,Gr,Bn,Un,Vr,Kr,Yr,Cl,Qr,jn,Xr,Zr,Jr,gt,Hn,Wn,zn,Gn,Vn,Kn,xr,tn,ea,ta,la,Ml,na,Ds,Is,Os,Rs=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",Ls,ml,rs,ia,Yn,Qn,sa,di,oa,vi,ra,Fs,Ft,as,aa,Xn,Zn,ua,hi,fa,us,fs,il,ca,ma,pa,Ul,qs,Jn,_a,cs,xn,da,ms,Bs,ln,Us,nn,js,sn,Hs,on,Gt,Ws,va;a=new Bt({}),L=new tp({});let xc=["NOK","SEK","DKK","EUR"],bi=[];for(let q=0;q<4;q+=1)bi[q]=pp(mp(t,xc,q));let kt=t[3].p.e&&t[0].chip!="esp8266"&&lf(t),wt=t[3].g.s>0&&nf(t);Dl=new Bt({});let e0=[24,48,96,192,384,576,1152],gi=[];for(let q=0;q<7;q+=1)gi[q]=_p(cp(t,e0,q));let yt=t[3].m.e.e&&sf(t),Ct=t[3].m.e.e&&of(t),Mt=t[3].m.m.e&&rf(t);Nn=new Bt({});let qt=t[0].if&&t[0].if.eth&&af(),Tt=(t[3].n.c==1||t[3].n.c==2)&&uf(t);Dn=new Bt({}),Rn=new Zc({});let St=t[3].n.m=="static"&&ff(t);Fn=new Bt({});let $t=t[0].chip!="esp8266"&&cf(t),ot=t[3].q.s.e&&mf(t),rt=t[3].q.m==3&&pf(t),at=t[3].q.m==4&&_f(t),ut=t[3].c.es!=null&&df(t),ft=Rs&&bf(t);Qn=new Bt({});let ei=t[7],vt=[];for(let q=0;q20||t[0].chip=="esp8266"||t[3].i.d.d>0)&&wf(t);Zn=new Bt({});let Nt=t[3].d.s&&Nf(t);return ln=new jt({props:{active:t[1],message:"Loading configuration"}}),nn=new jt({props:{active:t[2],message:"Saving configuration"}}),sn=new jt({props:{active:t[4],message:"Performing factory reset"}}),on=new jt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=b(),u=m("a"),re(a.$$.fragment),f=b(),c=m("input"),p=b(),_=m("div"),h=m("div"),d=m("div"),v=S("Hostname"),g=m("br"),A=b(),$=m("input"),M=b(),P=m("div"),F=S("Time zone"),E=m("br"),I=b(),D=m("select"),re(L.$$.fragment),ie=b(),H=m("input"),K=b(),G=m("div"),Y=m("div"),Q=m("div"),z=S("Price region"),Z=m("br"),V=b(),j=m("select"),ee=m("optgroup"),ue=m("option"),ue.textContent="NO1",x=m("option"),x.textContent="NO2",W=m("option"),W.textContent="NO3",U=m("option"),U.textContent="NO4",ke=m("option"),ke.textContent="NO5",He=m("optgroup"),Be=m("option"),Be.textContent="SE1",We=m("option"),We.textContent="SE2",Ne=m("option"),Ne.textContent="SE3",ge=m("option"),ge.textContent="SE4",Re=m("optgroup"),Me=m("option"),Me.textContent="DK1",T=m("option"),T.textContent="DK2",k=m("option"),k.textContent="Austria",w=m("option"),w.textContent="Belgium",N=m("option"),N.textContent="Czech Republic",R=m("option"),R.textContent="Estonia",J=m("option"),J.textContent="Finland",te=m("option"),te.textContent="France",fe=m("option"),fe.textContent="Germany",de=m("option"),de.textContent="Great Britain",we=m("option"),we.textContent="Latvia",Ee=m("option"),Ee.textContent="Lithuania",ae=m("option"),ae.textContent="Netherland",Ce=m("option"),Ce.textContent="Poland",Je=m("option"),Je.textContent="Switzerland",Et=b(),st=m("div"),ht=S("Currency"),lt=m("br"),At=b(),Ye=m("select");for(let q=0;q<4;q+=1)bi[q].c();Qt=b(),Ht=m("div"),bt=m("div"),ze=m("div"),xe=S("Fixed price"),Xe=m("br"),Ue=b(),qe=m("input"),et=b(),Ae=m("div"),Le=S("Multiplier"),pe=m("br"),ce=b(),ye=m("input"),zl=b(),hl=m("div"),_n=m("label"),Pt=m("input"),Ai=S(" Enable price fetch from remote server"),Pi=b(),kt&&kt.c(),Di=b(),bl=m("div"),Ii=S("Security"),Oi=m("br"),Ri=b(),Dt=m("select"),Nl=m("option"),Nl.textContent="None",El=m("option"),El.textContent="Only configuration",Al=m("option"),Al.textContent="Everything",Li=b(),wt&&wt.c(),Fi=b(),je=m("div"),dn=m("strong"),dn.textContent="Meter",qi=b(),Pl=m("a"),re(Dl.$$.fragment),Bi=b(),Gl=m("input"),Ze=b(),mt=m("input"),Vl=b(),Il=m("div"),Ui=S("Communication"),Ol=m("br"),ji=b(),Wt=m("select"),vn=m("option"),vn.textContent="Passive (Push)",hn=m("option"),hn.textContent="Kamstrup (Pull)",Eo=b(),rl=m("div"),Hi=m("span"),Hi.textContent="Buffer size",Ao=b(),Ss=m("span"),Ss.textContent="Serial conf.",Po=b(),fi=m("label"),Xt=m("input"),Do=S(" inverted"),Io=b(),Rl=m("div"),al=m("select"),Ll=m("option"),Oo=S("Autodetect");for(let q=0;q<7;q+=1)gi[q].c();Ro=b(),dt=m("select"),Fl=m("option"),Lo=S("-"),bn=m("option"),bn.textContent="7N1",gn=m("option"),gn.textContent="8N1",kn=m("option"),kn.textContent="7E1",wn=m("option"),wn.textContent="8E1",Fo=b(),It=m("input"),qo=b(),Kl=m("div"),Bo=S("Voltage"),Uo=m("br"),jo=b(),ul=m("select"),yn=m("option"),yn.textContent="400V (TN)",Cn=m("option"),Cn.textContent="230V (IT/TT)",Ho=b(),Mn=m("div"),Yl=m("div"),Wo=S("Main fuse"),zo=m("br"),Go=b(),Tn=m("label"),Zt=m("input"),Vo=b(),Ki=m("span"),Ki.textContent="A",Ko=b(),Ql=m("div"),Yo=S("Production"),Qo=m("br"),Xo=b(),Sn=m("label"),Jt=m("input"),Zo=b(),Yi=m("span"),Yi.textContent="kWp",Jo=b(),$s=m("div"),xo=b(),Xl=m("div"),Qi=m("label"),xt=m("input"),er=S(" Meter is encrypted"),tr=b(),yt&&yt.c(),lr=b(),Ct&&Ct.c(),Ns=b(),Xi=m("label"),el=m("input"),nr=S(" Multipliers"),ir=b(),Mt&&Mt.c(),sr=b(),Ot=m("div"),Zi=m("strong"),Zi.textContent="Connection",or=b(),$n=m("a"),re(Nn.$$.fragment),rr=b(),ci=m("input"),ar=b(),Zl=m("div"),ur=S("Connection"),fr=m("br"),cr=b(),zt=m("select"),En=m("option"),En.textContent="WiFi",An=m("option"),An.textContent="Access point",qt&&qt.c(),mr=b(),Tt&&Tt.c(),pr=b(),pt=m("div"),Ji=m("strong"),Ji.textContent="Network",_r=b(),Pn=m("a"),re(Dn.$$.fragment),dr=b(),Jl=m("div"),vr=S("IP"),hr=m("br"),br=b(),ql=m("div"),fl=m("select"),In=m("option"),In.textContent="DHCP",On=m("option"),On.textContent="Static",gr=b(),Rt=m("input"),kr=b(),Lt=m("select"),re(Rn.$$.fragment),wr=b(),St&&St.c(),Es=b(),ns=m("div"),is=m("label"),tl=m("input"),yr=S(" enable mDNS"),Cr=b(),mi=m("input"),Mr=b(),Bl=m("div"),Tr=S("NTP "),pi=m("label"),ll=m("input"),Sr=S(" obtain from DHCP"),$r=m("br"),Nr=b(),ss=m("div"),gl=m("input"),Er=b(),tt=m("div"),os=m("strong"),os.textContent="MQTT",Ar=b(),Ln=m("a"),re(Fn.$$.fragment),Pr=b(),_i=m("input"),Dr=b(),cl=m("div"),Ir=S(`Server diff --git a/lib/SvelteUi/app/src/lib/Header.svelte b/lib/SvelteUi/app/src/lib/Header.svelte index 24f9eacb..05e2df8f 100644 --- a/lib/SvelteUi/app/src/lib/Header.svelte +++ b/lib/SvelteUi/app/src/lib/Header.svelte @@ -66,7 +66,7 @@
{ 'MQTT: ' + mqttError(data.me) }
{/if} {#if data.ee > 0 || data.ee < 0} -
{ 'PriceAPI: ' + priceError(data.ee) }
+
{ 'Pricps: ' + priceError(data.ee) }
{/if}
diff --git a/lib/SvelteUi/include/AmsWebServer.h b/lib/SvelteUi/include/AmsWebServer.h index fec93406..e6bfbba2 100644 --- a/lib/SvelteUi/include/AmsWebServer.h +++ b/lib/SvelteUi/include/AmsWebServer.h @@ -17,7 +17,7 @@ #include "EnergyAccounting.h" #include "Uptime.h" #include "RemoteDebug.h" -#include "EntsoeApi.h" +#include "PriceService.h" #include "RealtimePlot.h" #if defined(ESP8266) @@ -44,7 +44,7 @@ public: void setMqtt(MQTTClient* mqtt); void setTimezone(Timezone* tz); void setMqttEnabled(bool); - void setEntsoeApi(EntsoeApi* eapi); + void setPriceService(PriceService* ps); void setPriceSettings(String region, String currency); void setMeterConfig(uint8_t distributionSystem, uint16_t mainFuse, uint16_t productionCapacity); void setMqttHandler(AmsMqttHandler* mqttHandler); @@ -58,7 +58,7 @@ private: HwTools* hw; Timezone* tz; - EntsoeApi* eapi = NULL; + PriceService* ps = NULL; AmsConfiguration* config; GpioConfig* gpioConfig; WebConfig webConfig; diff --git a/lib/SvelteUi/src/AmsWebServer.cpp b/lib/SvelteUi/src/AmsWebServer.cpp index 51af4c87..8bfa522e 100644 --- a/lib/SvelteUi/src/AmsWebServer.cpp +++ b/lib/SvelteUi/src/AmsWebServer.cpp @@ -143,8 +143,8 @@ void AmsWebServer::setMqttHandler(AmsMqttHandler* mqttHandler) { this->mqttHandler = mqttHandler; } -void AmsWebServer::setEntsoeApi(EntsoeApi* eapi) { - this->eapi = eapi; +void AmsWebServer::setPriceService(PriceService* ps) { + this->ps = ps; } void AmsWebServer::setMeterConfig(uint8_t distributionSystem, uint16_t mainFuse, uint16_t productionCapacity) { @@ -484,7 +484,7 @@ void AmsWebServer::dataJson() { wifiStatus, mqttStatus, mqttHandler == NULL ? 0 : (int) mqttHandler->lastError(), - price == ENTSOE_NO_VALUE ? "null" : String(price, 2).c_str(), + price == PRICE_NO_VALUE ? "null" : String(price, 2).c_str(), meterState->getMeterType(), distributionSystem, ea->getMonthMax(), @@ -502,11 +502,11 @@ void AmsWebServer::dataJson() { ea->getCostThisMonth(), ea->getProducedThisMonth(), ea->getIncomeThisMonth(), - eapi == NULL ? "false" : "true", + ps == NULL ? "false" : "true", priceRegion.c_str(), priceCurrency.c_str(), meterState->getLastError(), - eapi == NULL ? 0 : eapi->getLastError(), + ps == NULL ? 0 : ps->getLastError(), (uint32_t) now, checkSecurity(1, false) ? "true" : "false" ); @@ -679,48 +679,48 @@ void AmsWebServer::energyPriceJson() { float prices[36]; for(int i = 0; i < 36; i++) { - prices[i] = eapi == NULL ? ENTSOE_NO_VALUE : eapi->getValueForHour(i); + prices[i] = ps == NULL ? PRICE_NO_VALUE : ps->getValueForHour(i); } snprintf_P(buf, BufferSize, ENERGYPRICE_JSON, - eapi == NULL ? "" : eapi->getCurrency(), - eapi == NULL ? "" : eapi->getSource(), - prices[0] == ENTSOE_NO_VALUE ? "null" : String(prices[0], 4).c_str(), - prices[1] == ENTSOE_NO_VALUE ? "null" : String(prices[1], 4).c_str(), - prices[2] == ENTSOE_NO_VALUE ? "null" : String(prices[2], 4).c_str(), - prices[3] == ENTSOE_NO_VALUE ? "null" : String(prices[3], 4).c_str(), - prices[4] == ENTSOE_NO_VALUE ? "null" : String(prices[4], 4).c_str(), - prices[5] == ENTSOE_NO_VALUE ? "null" : String(prices[5], 4).c_str(), - prices[6] == ENTSOE_NO_VALUE ? "null" : String(prices[6], 4).c_str(), - prices[7] == ENTSOE_NO_VALUE ? "null" : String(prices[7], 4).c_str(), - prices[8] == ENTSOE_NO_VALUE ? "null" : String(prices[8], 4).c_str(), - prices[9] == ENTSOE_NO_VALUE ? "null" : String(prices[9], 4).c_str(), - prices[10] == ENTSOE_NO_VALUE ? "null" : String(prices[10], 4).c_str(), - prices[11] == ENTSOE_NO_VALUE ? "null" : String(prices[11], 4).c_str(), - prices[12] == ENTSOE_NO_VALUE ? "null" : String(prices[12], 4).c_str(), - prices[13] == ENTSOE_NO_VALUE ? "null" : String(prices[13], 4).c_str(), - prices[14] == ENTSOE_NO_VALUE ? "null" : String(prices[14], 4).c_str(), - prices[15] == ENTSOE_NO_VALUE ? "null" : String(prices[15], 4).c_str(), - prices[16] == ENTSOE_NO_VALUE ? "null" : String(prices[16], 4).c_str(), - prices[17] == ENTSOE_NO_VALUE ? "null" : String(prices[17], 4).c_str(), - prices[18] == ENTSOE_NO_VALUE ? "null" : String(prices[18], 4).c_str(), - prices[19] == ENTSOE_NO_VALUE ? "null" : String(prices[19], 4).c_str(), - prices[20] == ENTSOE_NO_VALUE ? "null" : String(prices[20], 4).c_str(), - prices[21] == ENTSOE_NO_VALUE ? "null" : String(prices[21], 4).c_str(), - prices[22] == ENTSOE_NO_VALUE ? "null" : String(prices[22], 4).c_str(), - prices[23] == ENTSOE_NO_VALUE ? "null" : String(prices[23], 4).c_str(), - prices[24] == ENTSOE_NO_VALUE ? "null" : String(prices[24], 4).c_str(), - prices[25] == ENTSOE_NO_VALUE ? "null" : String(prices[25], 4).c_str(), - prices[26] == ENTSOE_NO_VALUE ? "null" : String(prices[26], 4).c_str(), - prices[27] == ENTSOE_NO_VALUE ? "null" : String(prices[27], 4).c_str(), - prices[28] == ENTSOE_NO_VALUE ? "null" : String(prices[28], 4).c_str(), - prices[29] == ENTSOE_NO_VALUE ? "null" : String(prices[29], 4).c_str(), - prices[30] == ENTSOE_NO_VALUE ? "null" : String(prices[30], 4).c_str(), - prices[31] == ENTSOE_NO_VALUE ? "null" : String(prices[31], 4).c_str(), - prices[32] == ENTSOE_NO_VALUE ? "null" : String(prices[32], 4).c_str(), - prices[33] == ENTSOE_NO_VALUE ? "null" : String(prices[33], 4).c_str(), - prices[34] == ENTSOE_NO_VALUE ? "null" : String(prices[34], 4).c_str(), - prices[35] == ENTSOE_NO_VALUE ? "null" : String(prices[35], 4).c_str() + ps == NULL ? "" : ps->getCurrency(), + ps == NULL ? "" : ps->getSource(), + prices[0] == PRICE_NO_VALUE ? "null" : String(prices[0], 4).c_str(), + prices[1] == PRICE_NO_VALUE ? "null" : String(prices[1], 4).c_str(), + prices[2] == PRICE_NO_VALUE ? "null" : String(prices[2], 4).c_str(), + prices[3] == PRICE_NO_VALUE ? "null" : String(prices[3], 4).c_str(), + prices[4] == PRICE_NO_VALUE ? "null" : String(prices[4], 4).c_str(), + prices[5] == PRICE_NO_VALUE ? "null" : String(prices[5], 4).c_str(), + prices[6] == PRICE_NO_VALUE ? "null" : String(prices[6], 4).c_str(), + prices[7] == PRICE_NO_VALUE ? "null" : String(prices[7], 4).c_str(), + prices[8] == PRICE_NO_VALUE ? "null" : String(prices[8], 4).c_str(), + prices[9] == PRICE_NO_VALUE ? "null" : String(prices[9], 4).c_str(), + prices[10] == PRICE_NO_VALUE ? "null" : String(prices[10], 4).c_str(), + prices[11] == PRICE_NO_VALUE ? "null" : String(prices[11], 4).c_str(), + prices[12] == PRICE_NO_VALUE ? "null" : String(prices[12], 4).c_str(), + prices[13] == PRICE_NO_VALUE ? "null" : String(prices[13], 4).c_str(), + prices[14] == PRICE_NO_VALUE ? "null" : String(prices[14], 4).c_str(), + prices[15] == PRICE_NO_VALUE ? "null" : String(prices[15], 4).c_str(), + prices[16] == PRICE_NO_VALUE ? "null" : String(prices[16], 4).c_str(), + prices[17] == PRICE_NO_VALUE ? "null" : String(prices[17], 4).c_str(), + prices[18] == PRICE_NO_VALUE ? "null" : String(prices[18], 4).c_str(), + prices[19] == PRICE_NO_VALUE ? "null" : String(prices[19], 4).c_str(), + prices[20] == PRICE_NO_VALUE ? "null" : String(prices[20], 4).c_str(), + prices[21] == PRICE_NO_VALUE ? "null" : String(prices[21], 4).c_str(), + prices[22] == PRICE_NO_VALUE ? "null" : String(prices[22], 4).c_str(), + prices[23] == PRICE_NO_VALUE ? "null" : String(prices[23], 4).c_str(), + prices[24] == PRICE_NO_VALUE ? "null" : String(prices[24], 4).c_str(), + prices[25] == PRICE_NO_VALUE ? "null" : String(prices[25], 4).c_str(), + prices[26] == PRICE_NO_VALUE ? "null" : String(prices[26], 4).c_str(), + prices[27] == PRICE_NO_VALUE ? "null" : String(prices[27], 4).c_str(), + prices[28] == PRICE_NO_VALUE ? "null" : String(prices[28], 4).c_str(), + prices[29] == PRICE_NO_VALUE ? "null" : String(prices[29], 4).c_str(), + prices[30] == PRICE_NO_VALUE ? "null" : String(prices[30], 4).c_str(), + prices[31] == PRICE_NO_VALUE ? "null" : String(prices[31], 4).c_str(), + prices[32] == PRICE_NO_VALUE ? "null" : String(prices[32], 4).c_str(), + prices[33] == PRICE_NO_VALUE ? "null" : String(prices[33], 4).c_str(), + prices[34] == PRICE_NO_VALUE ? "null" : String(prices[34], 4).c_str(), + prices[35] == PRICE_NO_VALUE ? "null" : String(prices[35], 4).c_str() ); server.sendHeader(HEADER_CACHE_CONTROL, CACHE_CONTROL_NO_CACHE); @@ -827,8 +827,8 @@ void AmsWebServer::configurationJson() { MqttConfig mqttConfig; config->getMqttConfig(mqttConfig); - EntsoeConfig entsoe; - config->getEntsoeConfig(entsoe); + PriceServiceConfig price; + config->getPriceServiceConfig(price); DebugConfig debugConfig; config->getDebugConfig(debugConfig); DomoticzConfig domo; @@ -938,12 +938,12 @@ void AmsWebServer::configurationJson() { ); server.sendContent(buf); snprintf_P(buf, BufferSize, CONF_PRICE_JSON, - entsoe.enabled ? "true" : "false", - entsoe.token, - entsoe.area, - entsoe.currency, - entsoe.multiplier / 1000.0, - entsoe.fixedPrice == 0 ? "null" : String(entsoe.fixedPrice / 1000.0, 10).c_str() + price.enabled ? "true" : "false", + price.entsoeToken, + price.area, + price.currency, + price.multiplier / 1000.0, + price.fixedPrice == 0 ? "null" : String(price.fixedPrice / 1000.0, 10).c_str() ); server.sendContent(buf); snprintf_P(buf, BufferSize, CONF_DEBUG_JSON, @@ -1521,14 +1521,14 @@ void AmsWebServer::handleSave() { priceRegion = server.arg(F("pr")); - 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, priceRegion.c_str()); - strcpy(entsoe.currency, server.arg(F("pc")).c_str()); - entsoe.multiplier = server.arg(F("pm")).toFloat() * 1000; - entsoe.fixedPrice = server.hasArg(F("pf")) ? server.arg(F("pf")).toFloat() * 1000 : 0; - config->setEntsoeConfig(entsoe); + PriceServiceConfig price; + price.enabled = server.hasArg(F("pe")) && server.arg(F("pe")) == F("true"); + strcpy(price.entsoeToken, server.arg(F("pt")).c_str()); + strcpy(price.area, priceRegion.c_str()); + strcpy(price.currency, server.arg(F("pc")).c_str()); + price.multiplier = server.arg(F("pm")).toFloat() * 1000; + price.fixedPrice = server.hasArg(F("pf")) ? server.arg(F("pf")).toFloat() * 1000 : 0; + config->setPriceServiceConfig(price); } if(server.hasArg(F("t")) && server.arg(F("t")) == F("true")) { @@ -2081,7 +2081,7 @@ void AmsWebServer::configFileDownload() { bool includeMeter = server.hasArg(F("it")) && server.arg(F("it")) == F("true"); bool includeGpio = server.hasArg(F("ig")) && server.arg(F("ig")) == F("true"); bool includeNtp = server.hasArg(F("in")) && server.arg(F("in")) == F("true"); - bool includeEntsoe = server.hasArg(F("is")) && server.arg(F("is")) == F("true"); + bool includePrice = server.hasArg(F("is")) && server.arg(F("is")) == F("true"); bool includeThresholds = server.hasArg(F("ih")) && server.arg(F("ih")) == F("true"); SystemConfig sys; @@ -2219,14 +2219,14 @@ void AmsWebServer::configFileDownload() { server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("ntpServer %s\n"), ntp.server)); } - if(includeEntsoe) { - EntsoeConfig entsoe; - config->getEntsoeConfig(entsoe); - if(strlen(entsoe.token) == 36 && includeSecrets) server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("entsoeToken %s\n"), entsoe.token)); - server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("entsoeArea %s\n"), entsoe.area)); - server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("entsoeCurrency %s\n"), entsoe.currency)); - server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("entsoeMultiplier %.3f\n"), entsoe.multiplier / 1000.0)); - server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("entsoeFixedPrice %.3f\n"), entsoe.fixedPrice / 1000.0)); + if(includePrice) { + PriceServiceConfig price; + config->getPriceServiceConfig(price); + if(strlen(price.entsoeToken) == 36 && includeSecrets) server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("priceEntsoeToken %s\n"), price.entsoeToken)); + server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("priceArea %s\n"), price.area)); + server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("priceCurrency %s\n"), price.currency)); + server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("priceMultiplier %.3f\n"), price.multiplier / 1000.0)); + server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("priceFixedPrice %.3f\n"), price.fixedPrice / 1000.0)); } if(includeThresholds) { diff --git a/platformio.ini b/platformio.ini index 417f917b..5aaa0347 100755 --- a/platformio.ini +++ b/platformio.ini @@ -2,7 +2,7 @@ extra_configs = platformio-user.ini [common] -lib_deps = EEPROM, LittleFS, DNSServer, https://github.com/256dpi/arduino-mqtt.git, OneWireNg@0.10.0, DallasTemperature@3.9.1, EspSoftwareSerial@6.14.1, https://github.com/gskjold/RemoteDebug.git, Time@1.6.1, Timezone@1.2.4, FirmwareVersion, AmsConfiguration, AmsData, AmsDataStorage, HwTools, Uptime, AmsDecoder, EntsoePriceApi, EnergyAccounting, AmsMqttHandler, RawMqttHandler, JsonMqttHandler, DomoticzMqttHandler, HomeAssistantMqttHandler, RealtimePlot, SvelteUi +lib_deps = EEPROM, LittleFS, DNSServer, https://github.com/256dpi/arduino-mqtt.git, OneWireNg@0.10.0, DallasTemperature@3.9.1, EspSoftwareSerial@6.14.1, https://github.com/gskjold/RemoteDebug.git, Time@1.6.1, Timezone@1.2.4, FirmwareVersion, AmsConfiguration, AmsData, AmsDataStorage, HwTools, Uptime, AmsDecoder, PriceService, EnergyAccounting, AmsMqttHandler, RawMqttHandler, JsonMqttHandler, DomoticzMqttHandler, HomeAssistantMqttHandler, RealtimePlot, SvelteUi lib_ignore = OneWire extra_scripts = pre:scripts/addversion.py diff --git a/src/AmsToMqttBridge.cpp b/src/AmsToMqttBridge.cpp index 6bc54ea9..c2d01aef 100644 --- a/src/AmsToMqttBridge.cpp +++ b/src/AmsToMqttBridge.cpp @@ -62,7 +62,7 @@ ADC_MODE(ADC_VCC); #include "WiFiClientConnectionHandler.h" #include "WiFiAccessPointConnectionHandler.h" #include "EthernetConnectionHandler.h" -#include "EntsoeApi.h" +#include "PriceService.h" #include "RealtimePlot.h" #include "AmsWebServer.h" #include "AmsConfiguration.h" @@ -104,7 +104,7 @@ AmsConfiguration config; RemoteDebug Debug; -EntsoeApi* eapi = NULL; +PriceService* ps = NULL; Timezone* tz = NULL; @@ -179,7 +179,7 @@ void handleDataSuccess(AmsData* data); void handleTemperature(unsigned long now); void handleSystem(unsigned long now); void handleButton(unsigned long now); -void handlePriceApi(unsigned long now); +void handlePriceService(unsigned long now); void handleClear(unsigned long now); void handleEnergyAccountingChanged(); bool handleVoltageCheck(); @@ -294,14 +294,14 @@ void setup() { hw.ledBlink(LED_GREEN, 1); hw.ledBlink(LED_BLUE, 1); - EntsoeConfig entsoe; - if(config.getEntsoeConfig(entsoe) && entsoe.enabled && strlen(entsoe.area) > 0) { - eapi = new EntsoeApi(&Debug); - eapi->setup(entsoe); - ws.setEntsoeApi(eapi); + PriceServiceConfig price; + if(config.getPriceServiceConfig(price) && price.enabled && strlen(price.area) > 0) { + ps = new PriceService(&Debug); + ps->setup(price); + ws.setPriceService(ps); } - ws.setPriceSettings(entsoe.area, entsoe.currency); - ea.setFixedPrice(entsoe.fixedPrice / 1000.0, entsoe.currency); + ws.setPriceSettings(price.area, price.currency); + ea.setFixedPrice(price.fixedPrice / 1000.0, price.currency); bool shared = false; Serial.flush(); Serial.end(); @@ -478,7 +478,7 @@ void setup() { } ea.setup(&ds, eac); ea.load(); - ea.setEapi(eapi); + ea.setPriceService(ps); ws.setup(&config, &gpioConfig, &meterState, &ds, &ea, &rtp); #if defined(ESP32) @@ -573,7 +573,7 @@ void loop() { if(err > 0) debugE_P(PSTR("Energyspeedometer connector reporting error (%d)"), err); energySpeedometer->connect(); - energySpeedometer->publishSystem(&hw, eapi, &ea); + energySpeedometer->publishSystem(&hw, ps, &ea); } energySpeedometer->loop(); delay(10); @@ -590,9 +590,9 @@ void loop() { #endif try { - handlePriceApi(now); + handlePriceService(now); } catch(const std::exception& e) { - debugE_P(PSTR("Exception in ENTSO-E loop (%s)"), e.what()); + debugE_P(PSTR("Exception in PriceService loop (%s)"), e.what()); } start = millis(); ws.loop(); @@ -809,11 +809,11 @@ void handleSystem(unsigned long now) { start = millis(); if(WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED) { if(mqttHandler != NULL) { - mqttHandler->publishSystem(&hw, eapi, &ea); + mqttHandler->publishSystem(&hw, ps, &ea); } #if defined(ENERGY_SPEEDOMETER_PASS) if(energySpeedometer != NULL) { - energySpeedometer->publishSystem(&hw, eapi, &ea); + energySpeedometer->publishSystem(&hw, ps, &ea); } #endif } @@ -875,18 +875,18 @@ void handleTemperature(unsigned long now) { } } -void handlePriceApi(unsigned long now) { +void handlePriceService(unsigned long now) { unsigned long start, end; - if(eapi != NULL && ntpEnabled) { + if(ps != NULL && ntpEnabled) { start = millis(); - if(eapi->loop() && mqttHandler != NULL) { + if(ps->loop() && mqttHandler != NULL) { end = millis(); if(end - start > 1000) { debugW_P(PSTR("Used %dms to update prices"), millis()-start); } start = millis(); - mqttHandler->publishPrices(eapi); + mqttHandler->publishPrices(ps); end = millis(); if(end - start > 1000) { debugW_P(PSTR("Used %dms to publish prices to MQTT"), millis()-start); @@ -899,23 +899,23 @@ void handlePriceApi(unsigned long now) { } } - if(config.isEntsoeChanged()) { - EntsoeConfig entsoe; - if(config.getEntsoeConfig(entsoe) && entsoe.enabled && strlen(entsoe.area) > 0) { - if(eapi == NULL) { - eapi = new EntsoeApi(&Debug); - ea.setEapi(eapi); - ws.setEntsoeApi(eapi); + if(config.isPriceServiceChanged()) { + PriceServiceConfig price; + if(config.getPriceServiceConfig(price) && price.enabled && strlen(price.area) > 0) { + if(ps == NULL) { + ps = new PriceService(&Debug); + ea.setPriceService(ps); + ws.setPriceService(ps); } - eapi->setup(entsoe); - } else if(eapi != NULL) { - delete eapi; - eapi = NULL; - ws.setEntsoeApi(NULL); + ps->setup(price); + } else if(ps != NULL) { + delete ps; + ps = NULL; + ws.setPriceService(NULL); } - ws.setPriceSettings(entsoe.area, entsoe.currency); - config.ackEntsoeChange(); - ea.setFixedPrice(entsoe.fixedPrice / 1000.0, entsoe.currency); + ws.setPriceSettings(price.area, price.currency); + config.ackPriceServiceChange(); + ea.setFixedPrice(price.fixedPrice / 1000.0, price.currency); } } @@ -1111,12 +1111,12 @@ void handleDataSuccess(AmsData* data) { ESP.wdtFeed(); #endif yield(); - if(mqttHandler->publish(data, &meterState, &ea, eapi)) { + if(mqttHandler->publish(data, &meterState, &ea, ps)) { delay(10); } } #if defined(ENERGY_SPEEDOMETER_PASS) - if(energySpeedometer != NULL && energySpeedometer->publish(&meterState, &meterState, &ea, eapi)) { + if(energySpeedometer != NULL && energySpeedometer->publish(&meterState, &meterState, &ea, ps)) { delay(10); } #endif @@ -1261,7 +1261,7 @@ void MQTT_connect() { if(mqttHandler != NULL) { mqttHandler->connect(); - mqttHandler->publishSystem(&hw, eapi, &ea); + mqttHandler->publishSystem(&hw, ps, &ea); } } @@ -1284,7 +1284,7 @@ void configFileParse() { bool lDomo = false; bool lHa = false; bool lNtp = false; - bool lEntsoe = false; + bool lPrice = false; bool lEac = false; bool sEa = false; bool sDs = false; @@ -1300,7 +1300,7 @@ void configFileParse() { DomoticzConfig domo; HomeAssistantConfig haconf; NtpConfig ntp; - EntsoeConfig entsoe; + PriceServiceConfig price; EnergyAccountingConfig eac; size_t size; @@ -1499,20 +1499,35 @@ void configFileParse() { if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; }; strcpy(ntp.timezone, buf+12); } else if(strncmp_P(buf, PSTR("entsoeToken "), 12) == 0) { - if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; }; - strcpy(entsoe.token, buf+12); + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + strcpy(price.entsoeToken, buf+12); } else if(strncmp_P(buf, PSTR("entsoeArea "), 11) == 0) { - if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; }; - strcpy(entsoe.area, buf+11); + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + strcpy(price.area, buf+11); } else if(strncmp_P(buf, PSTR("entsoeCurrency "), 15) == 0) { - if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; }; - strcpy(entsoe.currency, buf+15); + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + strcpy(price.currency, buf+15); } else if(strncmp_P(buf, PSTR("entsoeMultiplier "), 17) == 0) { - if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; }; - entsoe.multiplier = String(buf+17).toFloat() * 1000; + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + price.multiplier = String(buf+17).toFloat() * 1000; } else if(strncmp_P(buf, PSTR("entsoeFixedPrice "), 17) == 0) { - if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; }; - entsoe.fixedPrice = String(buf+17).toFloat() * 1000; + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + price.fixedPrice = String(buf+17).toFloat() * 1000; + } else if(strncmp_P(buf, PSTR("priceEntsoeToken "), 17) == 0) { + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + strcpy(price.entsoeToken, buf+12); + } else if(strncmp_P(buf, PSTR("priceArea "), 10) == 0) { + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + strcpy(price.area, buf+11); + } else if(strncmp_P(buf, PSTR("priceCurrency "), 14) == 0) { + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + strcpy(price.currency, buf+15); + } else if(strncmp_P(buf, PSTR("priceMultiplier "), 16) == 0) { + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + price.multiplier = String(buf+17).toFloat() * 1000; + } else if(strncmp_P(buf, PSTR("priceFixedPrice "), 16) == 0) { + if(!lPrice) { config.getPriceServiceConfig(price); lPrice = true; }; + price.fixedPrice = String(buf+17).toFloat() * 1000; } else if(strncmp_P(buf, PSTR("thresholds "), 11) == 0) { if(!lEac) { config.getEnergyAccountingConfig(eac); lEac = true; }; int i = 0; @@ -1745,7 +1760,7 @@ void configFileParse() { if(lDomo) config.setDomoticzConfig(domo); if(lHa) config.setHomeAssistantConfig(haconf); if(lNtp) config.setNtpConfig(ntp); - if(lEntsoe) config.setEntsoeConfig(entsoe); + if(lPrice) config.setPriceServiceConfig(price); if(lEac) config.setEnergyAccountingConfig(eac); if(sDs) ds.save(); if(sEa) ea.save(); diff --git a/src/PassthroughMqttHandler.cpp b/src/PassthroughMqttHandler.cpp index e4f23046..44d4334a 100644 --- a/src/PassthroughMqttHandler.cpp +++ b/src/PassthroughMqttHandler.cpp @@ -7,7 +7,7 @@ #include "PassthroughMqttHandler.h" #include "hexutils.h" -bool PassthroughMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { +bool PassthroughMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) { return false; } @@ -15,11 +15,11 @@ bool PassthroughMqttHandler::publishTemperatures(AmsConfiguration*, HwTools*) { return false; } -bool PassthroughMqttHandler::publishPrices(EntsoeApi*) { +bool PassthroughMqttHandler::publishPrices(PriceService*) { return false; } -bool PassthroughMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { +bool PassthroughMqttHandler::publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea) { return false; } diff --git a/src/PassthroughMqttHandler.h b/src/PassthroughMqttHandler.h index b3b72f53..d2adc76c 100644 --- a/src/PassthroughMqttHandler.h +++ b/src/PassthroughMqttHandler.h @@ -14,10 +14,10 @@ public: PassthroughMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf) : AmsMqttHandler(mqttConfig, debugger, buf) { this->topic = String(mqttConfig.publishTopic); }; - bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); + bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, PriceService* ps); bool publishTemperatures(AmsConfiguration*, HwTools*); - bool publishPrices(EntsoeApi*); - bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishPrices(PriceService*); + bool publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea); bool publishBytes(uint8_t* buf, uint16_t len); bool publishString(char* str);