Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #452 reevaluate claims if amps > pilot #532

Merged
merged 5 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openevse-gui-v2
Submodule openevse-gui-v2 added at 3f2c8a
24 changes: 22 additions & 2 deletions src/evse_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ EvseMonitor::EvseMonitor(OpenEVSEClass &openevse) :
_stuck_count(0),
_min_current(0),
_pilot(0),
_pilot_is_wrong(false),
_max_configured_current(0),
_max_hardware_current(80),
_data_ready(EVSE_MONITOR_DATA_READY),
Expand Down Expand Up @@ -311,6 +312,22 @@ void EvseMonitor::updateEvseState(uint8_t evse_state, uint8_t pilot_state, uint3
}
}

void EvseMonitor::verifyPilot() {
// After some state changes the OpenEVSE module compiled with PP_AUTO_AMPACITY will reset to the maximum pilot level, so reset to what we expect
_openevse.getCurrentCapacity([this](int ret, long min_current, long max_hardware_current, long pilot, long max_configured_current)
{
if(RAPI_RESPONSE_OK == ret && pilot != getPilot())
KipK marked this conversation as resolved.
Show resolved Hide resolved
{
DBUGLN("#### Pilot is wrong set again");
DBUGVAR(pilot);
DBUGVAR(getPilot());
_pilot_is_wrong = true;
setPilot(getPilot());
_pilot_is_wrong = false;
KipK marked this conversation as resolved.
Show resolved Hide resolved
}
});
}

void EvseMonitor::updateCurrentSettings(long min_current, long max_hardware_current, long pilot, long max_configured_current)
{
DBUGF("min_current = %ld, pilot = %ld, max_configured_current = %ld, max_hardware_current = %ld", min_current, pilot, max_configured_current, max_hardware_current);
Expand All @@ -320,7 +337,6 @@ void EvseMonitor::updateCurrentSettings(long min_current, long max_hardware_curr
_max_configured_current = max_configured_current;
}


unsigned long EvseMonitor::loop(MicroTasks::WakeReason reason)
{
DBUG("EVSE monitor woke: ");
Expand Down Expand Up @@ -359,6 +375,10 @@ unsigned long EvseMonitor::loop(MicroTasks::WakeReason reason)
getEnergyFromEvse();
}

// Check if pilot is wrong ( solve OpenEvse fw compiled with -D PP_AUTO_AMPACITY)
if (isCharging())
verifyPilot();
KipK marked this conversation as resolved.
Show resolved Hide resolved

_count ++;

return EVSE_MONITOR_POLL_TIME;
Expand Down Expand Up @@ -464,7 +484,7 @@ void EvseMonitor::setPilot(long amps, std::function<void(int ret)> callback)
amps = _min_current;
}

if(amps == _pilot)
if(amps == _pilot && !_pilot_is_wrong)
KipK marked this conversation as resolved.
Show resolved Hide resolved
{
if(callback) {
callback(RAPI_RESPONSE_OK);
Expand Down
3 changes: 3 additions & 0 deletions src/evse_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class EvseMonitor : public MicroTasks::Task
char _firmware_version[32];
char _serial[16];

bool _pilot_is_wrong;

#ifdef ENABLE_MCP9808
Adafruit_MCP9808 _mcp9808;
#endif
Expand Down Expand Up @@ -209,6 +211,7 @@ class EvseMonitor : public MicroTasks::Task
void enableStuckRelayCheck(bool enabled, std::function<void(int ret)> callback = NULL);
void enableVentRequired(bool enabled, std::function<void(int ret)> callback = NULL);
void enableTemperatureCheck(bool enabled, std::function<void(int ret)> callback = NULL);
void verifyPilot();

uint8_t getEvseState() {
return _state.getEvseState();
Expand Down