Merge pull request #1040 from dalathegreat/feature/negative-SOC-scaling

Feature: Add negative SOC scaling 📉
This commit is contained in:
Daniel Öster 2025-04-13 11:35:18 +03:00 committed by GitHub
commit 15fce9073b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View file

@ -430,6 +430,12 @@ void update_calculated_values() {
calc_soc = 10000 * (calc_soc - datalayer.battery.settings.min_percentage);
calc_soc = calc_soc / (datalayer.battery.settings.max_percentage - datalayer.battery.settings.min_percentage);
datalayer.battery.status.reported_soc = calc_soc;
//Extra safety since we allow scaling negatively, if real% is < 1.00%, zero it out
if (datalayer.battery.status.real_soc < 100) {
datalayer.battery.status.reported_soc = 0;
} else {
datalayer.battery.status.reported_soc = calc_soc;
}
// Calculate the scaled remaining capacity in Wh
if (datalayer.battery.info.total_capacity_Wh > 0 && datalayer.battery.status.real_soc > 0) {

View file

@ -113,7 +113,7 @@ typedef struct {
/** Minimum percentage setting. Set this value to the lowest real SOC
* you want the inverter to be able to use. At this real SOC, the inverter
* will "see" 0% */
uint16_t min_percentage = BATTERY_MINPERCENTAGE;
int16_t min_percentage = BATTERY_MINPERCENTAGE;
/** Maximum percentage setting. Set this value to the highest real SOC
* you want the inverter to be able to use. At this real SOC, the inverter
* will "see" 100% */

View file

@ -209,10 +209,11 @@ String settings_processor(const String& var) {
"100.0');}}}";
content +=
"function editSocMin(){var value=prompt('Inverter will see completely discharged (0pct)SOC when this value is "
"reached. Enter new minimum SOC value that battery will discharge to "
"(0-50.0):');if(value!==null){if(value>=0&&value<=50){var xhr=new "
"reached. Advanced users can set to negative values. Enter new minimum SOC value that battery will discharge "
"to "
"(-10.0to50.0):');if(value!==null){if(value>=-10&&value<=50){var xhr=new "
"XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
"updateSocMin?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 and "
"updateSocMin?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between -10 and "
"50.0');}}}";
content +=
"function editMaxChargeA(){var value=prompt('Some inverters needs to be artificially limited. Enter new "