* fix another fixable "passtrough" typo the typo in the config's identifier is not changed to preserve compatibility while not spending the effort to migrate the setting. * webapp language: prefer SoC over SOC * DPL: implement solar passthrough loss factor in (full) solar passthrough mode, the inverter output power is coupled to the charge controler output power. the inverter efficiency is already accounted for. however, the battery might still be slowly discharged for two reasons: (1) line losses are not accounted for and (2) the inverter outputs a little bit more than permitted by the power limit. this is undesirable since the battery is significantly drained if solar passthrough is active for a longer period of time. also, when using full solar passthrough and a battery communication interface, the SoC will slowly degrade to a value below the threshold value for full solar passthrough. this makes the system switch from charging the battery (potentially rapidly) to discharging the battery slowly. this switch might happen in rather fast succession. that's effectively trickle-charging the battery. instead, this new factor helps to account for line losses between the solar charge controller and the inverter, such that the battery is actually not involved in solar passthrough. the value can be increased until it is observed that the battery is not discharging when solar passthrough is active.
196 lines
6.0 KiB
C++
196 lines
6.0 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#define CONFIG_FILENAME "/config.json"
|
|
#define CONFIG_VERSION 0x00011900 // 0.1.24 // make sure to clean all after change
|
|
|
|
#define WIFI_MAX_SSID_STRLEN 32
|
|
#define WIFI_MAX_PASSWORD_STRLEN 64
|
|
#define WIFI_MAX_HOSTNAME_STRLEN 31
|
|
|
|
#define NTP_MAX_SERVER_STRLEN 31
|
|
#define NTP_MAX_TIMEZONE_STRLEN 50
|
|
#define NTP_MAX_TIMEZONEDESCR_STRLEN 50
|
|
|
|
#define MQTT_MAX_HOSTNAME_STRLEN 128
|
|
#define MQTT_MAX_USERNAME_STRLEN 64
|
|
#define MQTT_MAX_PASSWORD_STRLEN 64
|
|
#define MQTT_MAX_TOPIC_STRLEN 256
|
|
#define MQTT_MAX_LWTVALUE_STRLEN 20
|
|
#define MQTT_MAX_CERT_STRLEN 2560
|
|
|
|
#define INV_MAX_NAME_STRLEN 31
|
|
#define INV_MAX_COUNT 5
|
|
#define INV_MAX_CHAN_COUNT 6
|
|
|
|
#define CHAN_MAX_NAME_STRLEN 31
|
|
|
|
#define DEV_MAX_MAPPING_NAME_STRLEN 63
|
|
|
|
#define POWERMETER_MAX_PHASES 3
|
|
#define POWERMETER_MAX_HTTP_URL_STRLEN 1024
|
|
#define POWERMETER_MAX_USERNAME_STRLEN 64
|
|
#define POWERMETER_MAX_PASSWORD_STRLEN 64
|
|
#define POWERMETER_MAX_HTTP_HEADER_KEY_STRLEN 64
|
|
#define POWERMETER_MAX_HTTP_HEADER_VALUE_STRLEN 256
|
|
#define POWERMETER_MAX_HTTP_JSON_PATH_STRLEN 256
|
|
#define POWERMETER_HTTP_TIMEOUT 1000
|
|
|
|
#define JSON_BUFFER_SIZE 15360
|
|
|
|
struct CHANNEL_CONFIG_T {
|
|
uint16_t MaxChannelPower;
|
|
char Name[CHAN_MAX_NAME_STRLEN];
|
|
float YieldTotalOffset;
|
|
};
|
|
|
|
struct INVERTER_CONFIG_T {
|
|
uint64_t Serial;
|
|
char Name[INV_MAX_NAME_STRLEN + 1];
|
|
uint8_t Order;
|
|
bool Poll_Enable;
|
|
bool Poll_Enable_Night;
|
|
bool Command_Enable;
|
|
bool Command_Enable_Night;
|
|
CHANNEL_CONFIG_T channel[INV_MAX_CHAN_COUNT];
|
|
};
|
|
|
|
enum Auth { none, basic, digest };
|
|
struct POWERMETER_HTTP_PHASE_CONFIG_T {
|
|
bool Enabled;
|
|
char Url[POWERMETER_MAX_HTTP_URL_STRLEN + 1];
|
|
Auth AuthType;
|
|
char Username[POWERMETER_MAX_USERNAME_STRLEN +1];
|
|
char Password[POWERMETER_MAX_USERNAME_STRLEN +1];
|
|
char HeaderKey[POWERMETER_MAX_HTTP_HEADER_KEY_STRLEN + 1];
|
|
char HeaderValue[POWERMETER_MAX_HTTP_HEADER_VALUE_STRLEN + 1];
|
|
uint16_t Timeout;
|
|
char JsonPath[POWERMETER_MAX_HTTP_JSON_PATH_STRLEN + 1];
|
|
};
|
|
|
|
struct CONFIG_T {
|
|
uint32_t Cfg_Version;
|
|
uint Cfg_SaveCount;
|
|
|
|
char WiFi_Ssid[WIFI_MAX_SSID_STRLEN + 1];
|
|
char WiFi_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
|
|
byte WiFi_Ip[4];
|
|
byte WiFi_Netmask[4];
|
|
byte WiFi_Gateway[4];
|
|
byte WiFi_Dns1[4];
|
|
byte WiFi_Dns2[4];
|
|
bool WiFi_Dhcp;
|
|
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
|
|
|
char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
|
|
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
|
|
char Ntp_TimezoneDescr[NTP_MAX_TIMEZONEDESCR_STRLEN + 1];
|
|
double Ntp_Longitude;
|
|
double Ntp_Latitude;
|
|
uint8_t Ntp_SunsetType;
|
|
|
|
bool Mqtt_Enabled;
|
|
uint Mqtt_Port;
|
|
char Mqtt_Username[MQTT_MAX_USERNAME_STRLEN + 1];
|
|
char Mqtt_Password[MQTT_MAX_PASSWORD_STRLEN + 1];
|
|
char Mqtt_Topic[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
bool Mqtt_Retain;
|
|
char Mqtt_LwtTopic[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
char Mqtt_LwtValue_Online[MQTT_MAX_LWTVALUE_STRLEN + 1];
|
|
char Mqtt_LwtValue_Offline[MQTT_MAX_LWTVALUE_STRLEN + 1];
|
|
uint32_t Mqtt_PublishInterval;
|
|
|
|
INVERTER_CONFIG_T Inverter[INV_MAX_COUNT];
|
|
|
|
uint64_t Dtu_Serial;
|
|
uint32_t Dtu_PollInterval;
|
|
uint8_t Dtu_NrfPaLevel;
|
|
int8_t Dtu_CmtPaLevel;
|
|
uint32_t Dtu_CmtFrequency;
|
|
|
|
bool Mqtt_Hass_Enabled;
|
|
bool Mqtt_Hass_Retain;
|
|
char Mqtt_Hass_Topic[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
bool Mqtt_Hass_IndividualPanels;
|
|
bool Mqtt_Tls;
|
|
char Mqtt_RootCaCert[MQTT_MAX_CERT_STRLEN + 1];
|
|
bool Mqtt_TlsCertLogin;
|
|
char Mqtt_ClientCert[MQTT_MAX_CERT_STRLEN + 1];
|
|
char Mqtt_ClientKey[MQTT_MAX_CERT_STRLEN +1];
|
|
|
|
bool Vedirect_Enabled;
|
|
bool Vedirect_UpdatesOnly;
|
|
|
|
char Mqtt_Hostname[MQTT_MAX_HOSTNAME_STRLEN + 1];
|
|
|
|
bool Mqtt_Hass_Expire;
|
|
|
|
bool PowerMeter_Enabled;
|
|
uint32_t PowerMeter_Interval;
|
|
uint32_t PowerMeter_Source;
|
|
char PowerMeter_MqttTopicPowerMeter1[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
char PowerMeter_MqttTopicPowerMeter2[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
char PowerMeter_MqttTopicPowerMeter3[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
uint32_t PowerMeter_SdmBaudrate;
|
|
uint32_t PowerMeter_SdmAddress;
|
|
uint32_t PowerMeter_HttpInterval;
|
|
bool PowerMeter_HttpIndividualRequests;
|
|
POWERMETER_HTTP_PHASE_CONFIG_T Powermeter_Http_Phase[POWERMETER_MAX_PHASES];
|
|
|
|
bool PowerLimiter_Enabled;
|
|
bool PowerLimiter_SolarPassThroughEnabled;
|
|
uint8_t PowerLimiter_SolarPassThroughLosses;
|
|
uint8_t PowerLimiter_BatteryDrainStategy;
|
|
uint32_t PowerLimiter_Interval;
|
|
bool PowerLimiter_IsInverterBehindPowerMeter;
|
|
uint8_t PowerLimiter_InverterId;
|
|
uint8_t PowerLimiter_InverterChannelId;
|
|
int32_t PowerLimiter_TargetPowerConsumption;
|
|
int32_t PowerLimiter_TargetPowerConsumptionHysteresis;
|
|
int32_t PowerLimiter_LowerPowerLimit;
|
|
int32_t PowerLimiter_UpperPowerLimit;
|
|
uint32_t PowerLimiter_BatterySocStartThreshold;
|
|
uint32_t PowerLimiter_BatterySocStopThreshold;
|
|
float PowerLimiter_VoltageStartThreshold;
|
|
float PowerLimiter_VoltageStopThreshold;
|
|
float PowerLimiter_VoltageLoadCorrectionFactor;
|
|
int8_t PowerLimiter_RestartHour;
|
|
uint32_t PowerLimiter_FullSolarPassThroughSoc;
|
|
float PowerLimiter_FullSolarPassThroughStartVoltage;
|
|
float PowerLimiter_FullSolarPassThroughStopVoltage;
|
|
|
|
bool Battery_Enabled;
|
|
bool Huawei_Enabled;
|
|
bool Huawei_Auto_Power_Enabled;
|
|
float Huawei_Auto_Power_Voltage_Limit;
|
|
float Huawei_Auto_Power_Enable_Voltage_Limit;
|
|
float Huawei_Auto_Power_Lower_Power_Limit;
|
|
float Huawei_Auto_Power_Upper_Power_Limit;
|
|
|
|
char Security_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
|
|
bool Security_AllowReadonly;
|
|
|
|
char Dev_PinMapping[DEV_MAX_MAPPING_NAME_STRLEN + 1];
|
|
|
|
bool Display_PowerSafe;
|
|
bool Display_ScreenSaver;
|
|
uint8_t Display_Rotation;
|
|
uint8_t Display_Contrast;
|
|
uint8_t Display_Language;
|
|
};
|
|
|
|
class ConfigurationClass {
|
|
public:
|
|
void init();
|
|
bool read();
|
|
bool write();
|
|
void migrate();
|
|
CONFIG_T& get();
|
|
|
|
INVERTER_CONFIG_T* getFreeInverterSlot();
|
|
INVERTER_CONFIG_T* getInverterConfig(uint64_t serial);
|
|
};
|
|
|
|
extern ConfigurationClass Configuration; |