mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Add missing settings
This commit is contained in:
parent
5fcbb68dd1
commit
ffd3e45a96
5 changed files with 40 additions and 7 deletions
|
@ -117,6 +117,8 @@ void init_stored_settings() {
|
||||||
mqtt_enabled = settings.getBool("MQTTENABLED", false);
|
mqtt_enabled = settings.getBool("MQTTENABLED", false);
|
||||||
ha_autodiscovery_enabled = settings.getBool("HADISC", false);
|
ha_autodiscovery_enabled = settings.getBool("HADISC", false);
|
||||||
|
|
||||||
|
custom_hostname = settings.getString("HOSTNAME").c_str();
|
||||||
|
|
||||||
mqtt_server = settings.getString("MQTTSERVER").c_str();
|
mqtt_server = settings.getString("MQTTSERVER").c_str();
|
||||||
mqtt_port = settings.getUInt("MQTTPORT", 0);
|
mqtt_port = settings.getUInt("MQTTPORT", 0);
|
||||||
mqtt_user = settings.getString("MQTTUSER").c_str();
|
mqtt_user = settings.getString("MQTTUSER").c_str();
|
||||||
|
|
|
@ -92,6 +92,10 @@ const char* name_for_button_type(STOP_BUTTON_BEHAVIOR behavior) {
|
||||||
|
|
||||||
String settings_processor(const String& var, BatteryEmulatorSettingsStore& settings) {
|
String settings_processor(const String& var, BatteryEmulatorSettingsStore& settings) {
|
||||||
|
|
||||||
|
if (var == "HOSTNAME") {
|
||||||
|
return settings.getString("HOSTNAME");
|
||||||
|
}
|
||||||
|
|
||||||
if (var == "BATTERYINTF") {
|
if (var == "BATTERYINTF") {
|
||||||
if (battery) {
|
if (battery) {
|
||||||
return battery->interface_name();
|
return battery->interface_name();
|
||||||
|
@ -131,6 +135,12 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var == "INVINTF") {
|
||||||
|
if (inverter) {
|
||||||
|
return inverter->interface_name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (var == "SHUNTCLASS") {
|
if (var == "SHUNTCLASS") {
|
||||||
if (!shunt) {
|
if (!shunt) {
|
||||||
return "hidden";
|
return "hidden";
|
||||||
|
@ -264,6 +274,14 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
||||||
return settings.getBool("HADISC") ? "checked" : "";
|
return settings.getBool("HADISC") ? "checked" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var == "MANUAL_BAL_CLASS") {
|
||||||
|
if (battery && battery->supports_manual_balancing()) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return "hidden";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (var == "BATTERY_WH_MAX") {
|
if (var == "BATTERY_WH_MAX") {
|
||||||
return String(datalayer.battery.info.total_capacity_Wh);
|
return String(datalayer.battery.info.total_capacity_Wh);
|
||||||
}
|
}
|
||||||
|
@ -664,6 +682,9 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
<label>Enable WiFi AP: </label>
|
<label>Enable WiFi AP: </label>
|
||||||
<input type='checkbox' name='WIFIAPENABLED' value='on' style='margin-left: 0;' %WIFIAPENABLED% />
|
<input type='checkbox' name='WIFIAPENABLED' value='on' style='margin-left: 0;' %WIFIAPENABLED% />
|
||||||
|
|
||||||
|
<label>Custom hostname: </label>
|
||||||
|
<input style='max-width: 250px;' type='text' name='HOSTNAME' value="%HOSTNAME%" />
|
||||||
|
|
||||||
<label>Enable MQTT: </label>
|
<label>Enable MQTT: </label>
|
||||||
<input type='checkbox' name='MQTTENABLED' value='on' onchange='toggleMqtt()' style='margin-left: 0;' %MQTTENABLED% />
|
<input type='checkbox' name='MQTTENABLED' value='on' onchange='toggleMqtt()' style='margin-left: 0;' %MQTTENABLED% />
|
||||||
|
|
||||||
|
|
|
@ -459,6 +459,8 @@ void init_webserver() {
|
||||||
} else if (p->name() == "SHUNTCOMM") {
|
} else if (p->name() == "SHUNTCOMM") {
|
||||||
auto type = static_cast<comm_interface>(atoi(p->value().c_str()));
|
auto type = static_cast<comm_interface>(atoi(p->value().c_str()));
|
||||||
settings.saveUInt("SHUNTCOMM", (int)type);
|
settings.saveUInt("SHUNTCOMM", (int)type);
|
||||||
|
} else if (p->name() == "HOSTNAME") {
|
||||||
|
settings.saveString("HOSTNAME", p->value().c_str());
|
||||||
} else if (p->name() == "MQTTSERVER") {
|
} else if (p->name() == "MQTTSERVER") {
|
||||||
settings.saveString("MQTTSERVER", p->value().c_str());
|
settings.saveString("MQTTSERVER", p->value().c_str());
|
||||||
} else if (p->name() == "MQTTPORT") {
|
} else if (p->name() == "MQTTPORT") {
|
||||||
|
@ -799,7 +801,7 @@ String processor(const String& var) {
|
||||||
content += "</style>";
|
content += "</style>";
|
||||||
|
|
||||||
// Compact header
|
// Compact header
|
||||||
content += "<h2>" + String(ssidAP.c_str()) + "</h2>";
|
content += "<h2>Battery Emulator</h2>";
|
||||||
|
|
||||||
// Start content block
|
// Start content block
|
||||||
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px; border-radius: 50px'>";
|
content += "<div style='background-color: #303E47; padding: 10px; margin-bottom: 10px; border-radius: 50px'>";
|
||||||
|
|
|
@ -30,6 +30,12 @@ const bool mdns_enabled_default = false;
|
||||||
#endif
|
#endif
|
||||||
bool mdns_enabled = mdns_enabled_default;
|
bool mdns_enabled = mdns_enabled_default;
|
||||||
|
|
||||||
|
#ifdef CUSTOM_HOSTNAME
|
||||||
|
std::string custom_hostname = CUSTOM_HOSTNAME;
|
||||||
|
#else
|
||||||
|
std::string custom_hostname;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string ssidAP;
|
std::string ssidAP;
|
||||||
|
|
||||||
// Configuration Parameters
|
// Configuration Parameters
|
||||||
|
@ -60,9 +66,9 @@ void init_WiFi() {
|
||||||
DEBUG_PRINTF("init_Wifi enabled=%d, apå=%d, ssid=%s, password=%s\n", wifi_enabled, wifiap_enabled, ssid.c_str(),
|
DEBUG_PRINTF("init_Wifi enabled=%d, apå=%d, ssid=%s, password=%s\n", wifi_enabled, wifiap_enabled, ssid.c_str(),
|
||||||
password.c_str());
|
password.c_str());
|
||||||
|
|
||||||
#ifdef CUSTOM_HOSTNAME
|
if (!custom_hostname.empty()) {
|
||||||
WiFi.setHostname(CUSTOM_HOSTNAME); // Set custom hostname if defined in USER_SETTINGS.h
|
WiFi.setHostname(custom_hostname.c_str());
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (wifiap_enabled) {
|
if (wifiap_enabled) {
|
||||||
WiFi.mode(WIFI_AP_STA); // Simultaneous WiFi AP and Router connection
|
WiFi.mode(WIFI_AP_STA); // Simultaneous WiFi AP and Router connection
|
||||||
|
@ -236,9 +242,10 @@ void init_mDNS() {
|
||||||
// e.g batteryemulator8C.local where the mac address is 08:F9:E0:D1:06:8C
|
// e.g batteryemulator8C.local where the mac address is 08:F9:E0:D1:06:8C
|
||||||
String mac = WiFi.macAddress();
|
String mac = WiFi.macAddress();
|
||||||
String mdnsHost = "batteryemulator" + mac.substring(mac.length() - 2);
|
String mdnsHost = "batteryemulator" + mac.substring(mac.length() - 2);
|
||||||
#ifdef CUSTOM_HOSTNAME // If CUSTOM_HOSTNAME is defined, use the same hostname also for mDNS
|
|
||||||
mdnsHost = CUSTOM_HOSTNAME;
|
if (!custom_hostname.empty()) {
|
||||||
#endif
|
mdnsHost = String(custom_hostname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize mDNS .local resolution
|
// Initialize mDNS .local resolution
|
||||||
if (!MDNS.begin(mdnsHost)) {
|
if (!MDNS.begin(mdnsHost)) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ extern std::string password;
|
||||||
extern const uint8_t wifi_channel;
|
extern const uint8_t wifi_channel;
|
||||||
extern std::string ssidAP;
|
extern std::string ssidAP;
|
||||||
extern std::string passwordAP;
|
extern std::string passwordAP;
|
||||||
|
extern std::string custom_hostname;
|
||||||
|
|
||||||
void init_WiFi();
|
void init_WiFi();
|
||||||
void wifi_monitor();
|
void wifi_monitor();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue