diff --git a/platformio.ini b/platformio.ini index f7ca2375..6b4a3cd8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,7 +36,7 @@ lib_deps = jeremypoulter/ArduinoMongoose@0.0.17 jeremypoulter/Micro Debug@0.0.5 jeremypoulter/ConfigJson@0.0.4 - jeremypoulter/OpenEVSE@0.0.10 + jeremypoulter/OpenEVSE@0.0.11 jeremypoulter/ESPAL@0.0.3 jeremypoulter/StreamSpy@0.0.1 jeremypoulter/MicroTasks@0.0.2 diff --git a/src/app_config.cpp b/src/app_config.cpp index 78f3c092..7c2a8baf 100644 --- a/src/app_config.cpp +++ b/src/app_config.cpp @@ -84,8 +84,6 @@ String tesla_vehicle_id; uint8_t led_brightness; #endif -long max_current_soft; - String esp_hostname_default = "openevse-"+ESPAL.getShortId(); void config_changed(String name); @@ -156,9 +154,6 @@ ConfigOpt *opts[] = new ConfigOptDefenition(led_brightness, LED_DEFAULT_BRIGHTNESS, "led_brightness", "lb"), #endif -// EVSE settings - new ConfigOptDefenition(max_current_soft, LONG_MAX, "max_current_soft", "mcs"), - // Flags &flagsOpt, @@ -243,8 +238,6 @@ void config_changed(String name) } else if(name == "led_brightness") { ledManager.setBrightness(led_brightness); #endif - } else if(name == "max_current_soft") { - evse.setMaxConfiguredCurrent(max_current_soft); } } diff --git a/src/evse_monitor.cpp b/src/evse_monitor.cpp index a59baf50..5db76dad 100644 --- a/src/evse_monitor.cpp +++ b/src/evse_monitor.cpp @@ -313,12 +313,9 @@ void EvseMonitor::updateCurrentSettings(long min_current, long max_hardware_curr { DBUGF("min_current = %ld, pilot = %ld, max_configured_current = %ld, max_hardware_current = %ld", min_current, pilot, max_configured_current, max_hardware_current); _min_current = min_current; - // The max_configured_current is a write once value, so as fare as we are concerned that is the 'hardware' max. We manage the acrual soft limit in the WiFi code. - _max_hardware_current = max_configured_current; + _max_hardware_current = max_hardware_current; _pilot = pilot; - if(_max_configured_current > _max_hardware_current || _max_configured_current < _min_current) { - _max_configured_current = _max_hardware_current; - } + _max_configured_current = max_configured_current; } @@ -654,10 +651,19 @@ void EvseMonitor::setMaxConfiguredCurrent(long amps) amps = _min_current; } - _max_configured_current = amps; - DBUGVAR(_max_configured_current); + _openevse.setCurrentCapacity(amps, true, [this, amps](int ret, long pilot) + { + if(RAPI_RESPONSE_OK == ret) + { + _max_configured_current = amps; + DBUGVAR(_max_configured_current); - _settings_changed.Trigger(); + _pilot = pilot; + DBUGVAR(_pilot); + + _settings_changed.Trigger(); + } + }); } void EvseMonitor::getStatusFromEvse(bool allowStart) diff --git a/src/web_server_config.cpp b/src/web_server_config.cpp index d7d96945..f2b6c0e4 100644 --- a/src/web_server_config.cpp +++ b/src/web_server_config.cpp @@ -150,6 +150,15 @@ handleConfigPost(MongooseHttpServerRequest *request, MongooseHttpServerResponseS DBUGLN("service changed"); } } + if(doc.containsKey("max_current_soft")) + { + long current = doc["max_current_soft"]; + if(current != evse.getMaxConfiguredCurrent()) { + evse.setMaxConfiguredCurrent(current); + config_modified = true; + DBUGLN("max_current_soft changed"); + } + } if(doc.containsKey("scale") && doc.containsKey("offset")) { long scale = doc["scale"]; diff --git a/test/claims.http b/test/claims.http index bc5febe0..2f021e14 100644 --- a/test/claims.http +++ b/test/claims.http @@ -32,7 +32,8 @@ Content-Type: application/json { "state": "active", - "auto_release": true + "auto_release": true, + "charge_current": 20 } ###