From 2c439115eb0e421e0b9997f6f9f61725180ee7fa Mon Sep 17 00:00:00 2001 From: KipK Date: Tue, 2 May 2023 11:39:54 +0200 Subject: [PATCH] new default_state flag --- src/app_config.cpp | 1 + src/app_config.h | 7 +++++++ src/evse_man.cpp | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app_config.cpp b/src/app_config.cpp index 7e86fc13..15192111 100644 --- a/src/app_config.cpp +++ b/src/app_config.cpp @@ -234,6 +234,7 @@ ConfigOpt *opts[] = new ConfigOptVirtualBool(flagsOpt, CONFIG_FACTORY_WRITE_LOCK, CONFIG_FACTORY_WRITE_LOCK, "factory_write_lock", "fwl"), new ConfigOptVirtualBool(flagsOpt, CONFIG_THREEPHASE, CONFIG_THREEPHASE, "is_threephase", "itp"), new ConfigOptVirtualBool(flagsOpt, CONFIG_WIZARD, CONFIG_WIZARD, "wizard_passed", "wzp"), + new ConfigOptVirtualBool(flagsOpt, CONFIG_DEFAULT_STATE, CONFIG_DEFAULT_STATE, "default_state", "dfs"), new ConfigOptVirtualMqttProtocol(flagsOpt, "mqtt_protocol", "mprt"), new ConfigOptVirtualChargeMode(flagsOpt, "charge_mode", "chmd") }; diff --git a/src/app_config.h b/src/app_config.h index ce313575..85cf65af 100644 --- a/src/app_config.h +++ b/src/app_config.h @@ -3,6 +3,7 @@ #include #include +#include "evse_state.h" #ifndef ENABLE_CONFIG_V1_IMPORT #define ENABLE_CONFIG_V1_IMPORT 1 @@ -119,6 +120,7 @@ extern uint32_t flags; #define CONFIG_OCPP_OFFLINE_AUTH (1 << 23) #define CONFIG_THREEPHASE (1 << 24) #define CONFIG_WIZARD (1 << 25) +#define CONFIG_DEFAULT_STATE (1 << 26) inline bool config_emoncms_enabled() { return CONFIG_SERVICE_EMONCMS == (flags & CONFIG_SERVICE_EMONCMS); @@ -205,6 +207,11 @@ inline bool config_wizard_passed() return CONFIG_WIZARD == (flags & CONFIG_WIZARD); } +inline EvseState config_default_state() +{ + return CONFIG_DEFAULT_STATE == (flags & CONFIG_DEFAULT_STATE) ? EvseState::Active : EvseState::Disabled; +} + // Ohm Connect Settings extern String ohm; diff --git a/src/evse_man.cpp b/src/evse_man.cpp index 0ee84040..1cd69c20 100644 --- a/src/evse_man.cpp +++ b/src/evse_man.cpp @@ -166,7 +166,7 @@ bool EvseManager::evaluateClaims(EvseProperties &properties) { // Clear the target state and set to active by default properties.clear(); - properties.setState(EvseState::Active); + properties.setState(config_default_state()); bool foundClaim = false; @@ -456,7 +456,7 @@ bool EvseManager::release(EvseClient client) event["claims_version"] = ++_version; if (client == EvseClient_OpenEVSE_Manual) { event["override_version"] = manual.setVersion(manual.getVersion() + 1); - + } event_send(event); return true;