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 all 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
25 changes: 22 additions & 3 deletions src/evse_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,20 @@ 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())
{
DBUGLN("#### Pilot is wrong set again");
DBUGVAR(pilot);
DBUGVAR(getPilot());
setPilot(getPilot(), true);
}
});
}

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 +334,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 +372,12 @@ 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();
}


_count ++;

return EVSE_MONITOR_POLL_TIME;
Expand Down Expand Up @@ -454,7 +473,7 @@ void EvseMonitor::disable()
});
}

void EvseMonitor::setPilot(long amps, std::function<void(int ret)> callback)
void EvseMonitor::setPilot(long amps, bool force, std::function<void(int ret)> callback)
{
// limit `amps` to the software limit
if(amps > _max_configured_current) {
Expand All @@ -464,7 +483,7 @@ void EvseMonitor::setPilot(long amps, std::function<void(int ret)> callback)
amps = _min_current;
}

if(amps == _pilot)
if(amps == _pilot && !force)
{
if(callback) {
callback(RAPI_RESPONSE_OK);
Expand Down
3 changes: 2 additions & 1 deletion src/evse_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class EvseMonitor : public MicroTasks::Task

void setMaxConfiguredCurrent(long amps);

void setPilot(long amps, std::function<void(int ret)> callback = NULL);
void setPilot(long amps, bool force=false, std::function<void(int ret)> callback = NULL);
void setVoltage(double volts, std::function<void(int ret)> callback = NULL);
void setServiceLevel(ServiceLevel level, std::function<void(int ret)> callback = NULL);
void configureCurrentSensorScale(long scale, long offset, std::function<void(int ret)> callback = NULL);
Expand All @@ -209,6 +209,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