Skip to content

Commit 35c6876

Browse files
committed
fix missing shaper_updated in /status
1 parent 3fdc923 commit 35c6876

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/current_shaper.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,29 @@ unsigned long CurrentShaperTask::loop(MicroTasks::WakeReason reason) {
3030
props.setState(EvseState::None);
3131
}
3232
_changed = false;
33+
_updated = true;
3334
_timer = millis();
3435
evse.claim(EvseClient_OpenEVSE_Shaper,EvseManager_Priority_Safety, props);
3536
StaticJsonDocument<128> event;
3637
event["shaper"] = 1;
3738
event["shaper_live_pwr"] = _live_pwr;
3839
event["shaper_max_pwr"] = _max_pwr;
3940
event["shaper_cur"] = _max_cur;
40-
event["shaper_updated"] = true;
41+
event["shaper_updated"] = _updated;
4142
event_send(event);
4243
}
4344
if (millis() - _timer > EVSE_SHAPER_FAILSAFE_TIME) {
4445
//available power has not been updated since EVSE_SHAPER_FAILSAFE_TIME, pause charge
4546
DBUGF("shaper_live_pwr has not been updated in time, pausing charge");
47+
_updated = false;
4648
props.setState(EvseState::Disabled);
4749
evse.claim(EvseClient_OpenEVSE_Shaper,EvseManager_Priority_Limit, props);
4850
StaticJsonDocument<128> event;
4951
event["shaper"] = 1;
5052
event["shaper_live_pwr"] = _live_pwr;
5153
event["shaper_max_pwr"] = _max_pwr;
5254
event["shaper_cur"] = _max_cur;
53-
event["shaper_updated"] = false;
55+
event["shaper_updated"] = _updated;
5456
event_send(event);
5557
}
5658
}
@@ -71,7 +73,8 @@ void CurrentShaperTask::begin(EvseManager &evse) {
7173
this -> _evse = &evse;
7274
this -> _max_pwr = current_shaper_max_pwr;
7375
this -> _live_pwr = 0;
74-
this -> _max_cur = 0;
76+
this -> _max_cur = 0;
77+
this -> _updated = false;
7578
MicroTask.startTask(this);
7679
StaticJsonDocument<128> event;
7780
event["shaper"] = 1;
@@ -112,6 +115,7 @@ void CurrentShaperTask::setState(bool state) {
112115
}
113116

114117
void CurrentShaperTask::shapeCurrent() {
118+
_updated = true;
115119
_max_cur = round(((_max_pwr - _live_pwr) / evse.getVoltage()) + (evse.getAmps()));
116120
_changed = true;
117121
}
@@ -132,4 +136,8 @@ bool CurrentShaperTask::getState() {
132136

133137
bool CurrentShaperTask::isActive() {
134138
return _evse->clientHasClaim(EvseClient_OpenEVSE_Shaper);
139+
}
140+
141+
bool CurrentShaperTask::isUpdated() {
142+
return _updated;
135143
}

src/current_shaper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CurrentShaperTask: public MicroTasks::Task
2929
uint8_t _chg_cur; // calculated charge current to claim
3030
uint8_t _max_cur; // shaper calculated max current
3131
uint32_t _timer;
32+
bool _updated;
3233

3334
protected:
3435
void setup();
@@ -49,6 +50,7 @@ class CurrentShaperTask: public MicroTasks::Task
4950
int getLivePwr();
5051
uint8_t getMaxCur();
5152
bool isActive();
53+
bool isUpdated();
5254

5355
void notifyConfigChanged(bool enabled, uint32_t max_pwr);
5456
};

src/web_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void buildStatus(DynamicJsonDocument &doc) {
246246
doc["shaper_live_pwr"] = shaper.getLivePwr();
247247
// doc["shaper_cur"] = shaper.getChgCur();
248248
doc["shaper_cur"] = shaper.getMaxCur();
249-
249+
doc["shaper_updated"] = shaper.isUpdated();
250250
doc["service_level"] = static_cast<uint8_t>(evse.getActualServiceLevel());
251251

252252
doc["ota_update"] = (int)Update.isRunning();

0 commit comments

Comments
 (0)