Skip to content

Commit e31faf5

Browse files
committed
prevent shaper to control charge_current if divert mode is active
fix shaper event reporting too late
1 parent d486e3c commit e31faf5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/current_shaper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,18 @@ void CurrentShaperTask::setState(bool state) {
9797
if (!_enabled) {
9898
//remove claim
9999
evse.release(EvseClient_OpenEVSE_Shaper);
100-
101100
}
102101
StaticJsonDocument<128> event;
103102
event["shaper"] = state?1:0;
104103
event_send(event);
105104
}
106105

107106
void CurrentShaperTask::shapeCurrent() {
107+
// only use Shaper if there's no Divert claim active ( means divert is active)
108+
if (!_evse->clientHasClaim(EvseClient_OpenEVSE_Divert)) {
108109
_chg_cur = round(((_max_pwr - _live_pwr) / evse.getVoltage()) + (evse.getAmps()));
109-
_changed = true; // update claim in the loop
110+
_changed = true;
111+
}
110112
}
111113

112114
int CurrentShaperTask::getMaxPwr() {

src/web_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void buildStatus(DynamicJsonDocument &doc) {
241241
doc["divert_update"] = (millis() - divert.getLastUpdate()) / 1000;
242242
doc["divert_active"] = divert.isActive();
243243

244-
doc["shaper"] = shaper.isActive()?1:0;
244+
doc["shaper"] = shaper.getState()?1:0;
245245
doc["shaper_live_pwr"] = shaper.getLivePwr();
246246
doc["shaper_chg_cur"] = shaper.getChgCur();
247247

0 commit comments

Comments
 (0)