mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Move SOFAR_ID to new setting mechanism.
This commit is contained in:
parent
ce1f8955e9
commit
7a2e2519cd
3 changed files with 18 additions and 14 deletions
|
@ -193,10 +193,7 @@ void store_settings() {
|
||||||
if (!settings.putUInt("TARGETDISCHVOLT", datalayer.battery.settings.max_user_set_discharge_voltage_dV)) {
|
if (!settings.putUInt("TARGETDISCHVOLT", datalayer.battery.settings.max_user_set_discharge_voltage_dV)) {
|
||||||
set_event(EVENT_PERSISTENT_SAVE_INFO, 11);
|
set_event(EVENT_PERSISTENT_SAVE_INFO, 11);
|
||||||
}
|
}
|
||||||
if (!settings.putUInt("SOFAR_ID", datalayer.battery.settings.sofar_user_specified_battery_id)) {
|
if (!settings.putUInt("BMSRESETDUR", datalayer.battery.settings.user_set_bms_reset_duration_ms)) {
|
||||||
set_event(EVENT_PERSISTENT_SAVE_INFO, 12);
|
|
||||||
}
|
|
||||||
if (!settings.putUInt("BMSRESETDUR", datalayer.battery.settings.sofar_user_specified_battery_id)) {
|
|
||||||
set_event(EVENT_PERSISTENT_SAVE_INFO, 13);
|
set_event(EVENT_PERSISTENT_SAVE_INFO, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -468,6 +468,10 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
||||||
return String(datalayer.charger.charger_setpoint_HV_IDC, 1);
|
return String(datalayer.charger.charger_setpoint_HV_IDC, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var == "SOFAR_ID") {
|
||||||
|
return String(settings.getUInt("SOFAR_ID", 0));
|
||||||
|
}
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,10 +531,6 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
function editPassword(){var value=prompt('Enter new password:');if(value!==null){var xhr=new
|
function editPassword(){var value=prompt('Enter new password:');if(value!==null){var xhr=new
|
||||||
XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/updatePassword?value='+encodeURIComponent(value),true);xhr.send();}}
|
XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/updatePassword?value='+encodeURIComponent(value),true);xhr.send();}}
|
||||||
|
|
||||||
function editSofarID(){var value=prompt('For double battery setups. Which battery ID should this emulator send? Remember to reboot after configuring this! Enter new value between (0-15):');
|
|
||||||
if(value!==null){if(value>=0&&value<=15){var xhr=new XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/updateSofarID?value='+value,true);xhr.send();}
|
|
||||||
else {alert('Invalid value. Please enter a value between 0 and 15.');}}}
|
|
||||||
|
|
||||||
function editWh(){var value=prompt('How much energy the battery can store. Enter new Wh value (1-400000):');
|
function editWh(){var value=prompt('How much energy the battery can store. Enter new Wh value (1-400000):');
|
||||||
if(value!==null){if(value>=1&&value<=400000){var xhr=new
|
if(value!==null){if(value>=1&&value<=400000){var xhr=new
|
||||||
XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/updateBatterySize?value='+value,true);xhr.send();}else{
|
XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/updateBatterySize?value='+value,true);xhr.send();}else{
|
||||||
|
@ -663,6 +663,11 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form .if-sofar { display: none; }
|
||||||
|
form[data-inverter="17"] .if-sofar {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
form .if-mqtt { display: none; }
|
form .if-mqtt { display: none; }
|
||||||
form[data-mqttenabled="true"] .if-mqtt {
|
form[data-mqttenabled="true"] .if-mqtt {
|
||||||
display: contents;
|
display: contents;
|
||||||
|
@ -726,6 +731,11 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="if-sofar">
|
||||||
|
<label>Sofar Battery ID (0-15): </label>
|
||||||
|
<input name='SOFAR_ID' type='text' value="%SOFAR_ID%" pattern="^[0-9]{1,2}$" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<label>Charger: </label><select name='charger'>
|
<label>Charger: </label><select name='charger'>
|
||||||
%CHGTYPE%
|
%CHGTYPE%
|
||||||
</select>
|
</select>
|
||||||
|
@ -827,8 +837,6 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
||||||
|
|
||||||
<h4 style='color: white;' class="%INVCLASS%">Inverter interface: <span id='Inverter'>%INVINTF%</span></h4>
|
<h4 style='color: white;' class="%INVCLASS%">Inverter interface: <span id='Inverter'>%INVINTF%</span></h4>
|
||||||
|
|
||||||
<h4 style='color: white;' class="%INVBIDCLASS%">Battery ID: <span>%INVBID%</span> <button onclick='editSofarID()'>Edit</button></h4>
|
|
||||||
|
|
||||||
<h4 style='color: white;' class="%SHUNTCLASS%">Shunt interface: <span id='Inverter'>%SHUNTINTF%</span></h4>
|
<h4 style='color: white;' class="%SHUNTCLASS%">Shunt interface: <span id='Inverter'>%SHUNTINTF%</span></h4>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -494,6 +494,9 @@ void init_webserver() {
|
||||||
settings.saveString("MQTTDEVICENAME", p->value().c_str());
|
settings.saveString("MQTTDEVICENAME", p->value().c_str());
|
||||||
} else if (p->name() == "HADEVICEID") {
|
} else if (p->name() == "HADEVICEID") {
|
||||||
settings.saveString("HADEVICEID", p->value().c_str());
|
settings.saveString("HADEVICEID", p->value().c_str());
|
||||||
|
} else if (p->name() == "SOFAR_ID") {
|
||||||
|
auto type = atoi(p->value().c_str());
|
||||||
|
settings.saveUInt("SOFAR_ID", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& boolSetting : boolSettings) {
|
for (auto& boolSetting : boolSettings) {
|
||||||
|
@ -579,10 +582,6 @@ void init_webserver() {
|
||||||
update_string_setting(route, [setter](String value) { setter(value.toInt()); });
|
update_string_setting(route, [setter](String value) { setter(value.toInt()); });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Route for editing Sofar ID
|
|
||||||
update_int_setting("/updateSofarID",
|
|
||||||
[](int value) { datalayer.battery.settings.sofar_user_specified_battery_id = value; });
|
|
||||||
|
|
||||||
// Route for editing Wh
|
// Route for editing Wh
|
||||||
update_int_setting("/updateBatterySize", [](int value) { datalayer.battery.info.total_capacity_Wh = value; });
|
update_int_setting("/updateBatterySize", [](int value) { datalayer.battery.info.total_capacity_Wh = value; });
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue