From 2f79e068046261def0d10056dbe985c62279ccfd Mon Sep 17 00:00:00 2001 From: Jeremy Poulter Date: Sat, 4 Jun 2022 11:05:09 +0100 Subject: [PATCH] Adding back the ability to use disabled instead of sleep to stop charging --- src/app_config.cpp | 1 + src/evse_man.cpp | 18 ++++++++++++++++++ src/evse_man.h | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/src/app_config.cpp b/src/app_config.cpp index ec8c8f03..b8956d24 100644 --- a/src/app_config.cpp +++ b/src/app_config.cpp @@ -229,6 +229,7 @@ void config_changed(String name) emoncms_updated = true; } ArduinoOcppTask::notifyConfigChanged(); + evse.setSleepForDisable(!config_pause_uses_disabled()); } else if(name.startsWith("mqtt_")) { mqtt_restart(); } else if(name.startsWith("ocpp_") || name.startsWith("tx_start_point")) { diff --git a/src/evse_man.cpp b/src/evse_man.cpp index 5bbe95aa..69068bb4 100644 --- a/src/evse_man.cpp +++ b/src/evse_man.cpp @@ -315,6 +315,24 @@ bool EvseManager::setTargetState(EvseProperties &target) return changeMade; } +void EvseManager::setSleepForDisable(bool sleepForDisable) +{ + if(_sleepForDisable != sleepForDisable) + { + _sleepForDisable = sleepForDisable; + if(EvseState::Disabled == getActiveState()) + { + if(_sleepForDisable) { + DBUGLN("EVSE: sleep"); + _monitor.sleep(); + } else { + DBUGLN("EVSE: disable"); + _monitor.disable(); + } + } + } +} + unsigned long EvseManager::loop(MicroTasks::WakeReason reason) { DBUG("EVSE manager woke: "); diff --git a/src/evse_man.h b/src/evse_man.h index edf07261..9c83be83 100644 --- a/src/evse_man.h +++ b/src/evse_man.h @@ -459,6 +459,12 @@ class EvseManager : public MicroTasks::Task void setVehicleRange(int vehicleRange); void setVehicleEta(int vehicleEta); + // Get/set the 'disabled' mode + bool isSleepForDisable() { + return _sleepForDisable; + } + void setSleepForDisable(bool sleepForDisable); + // Temp until everything uses EvseManager RapiSender &getSender() { return _sender;