Skip to content

Commit 4df4ebd

Browse files
committed
Code to allow using the disabled state to pause charging rather than sleep
Fixes issues with some cars not weaking up. #83
1 parent 5f38c09 commit 4df4ebd

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/app_config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ ConfigOpt *opts[] =
129129
new ConfigOptVirtualBool(flagsOpt, CONFIG_SERVICE_SNTP, CONFIG_SERVICE_SNTP, "sntp_enabled", "se"),
130130
new ConfigOptVirtualBool(flagsOpt,CONFIG_SERVICE_TESLA,CONFIG_SERVICE_TESLA, "tesla_enabled", "te"),
131131
new ConfigOptVirtualBool(flagsOpt, CONFIG_SERVICE_DIVERT, CONFIG_SERVICE_DIVERT, "divert_enabled", "de"),
132+
new ConfigOptVirtualBool(flagsOpt, CONFIG_PAUSE_USES_DISABLED, CONFIG_PAUSE_USES_DISABLED, "pause_uses_disabled", "pd"),
132133
new ConfigOptVirtualMqttProtocol(flagsOpt, "mqtt_protocol", "mprt"),
133134
new ConfigOptVirtualChargeMode(flagsOpt, "charge_mode", "chmd")
134135
};

src/app_config.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ extern uint32_t divert_min_charge_time;
5353
// 24-bits of Flags
5454
extern uint32_t flags;
5555

56-
#define CONFIG_SERVICE_EMONCMS (1 << 0)
57-
#define CONFIG_SERVICE_MQTT (1 << 1)
58-
#define CONFIG_SERVICE_OHM (1 << 2)
59-
#define CONFIG_SERVICE_SNTP (1 << 3)
60-
#define CONFIG_MQTT_PROTOCOL (7 << 4) // Maybe leave a bit of space after for additional protocols
61-
#define CONFIG_MQTT_ALLOW_ANY_CERT (1 << 7)
62-
#define CONFIG_SERVICE_TESLA (1 << 8)
63-
#define CONFIG_SERVICE_DIVERT (1 << 9)
64-
#define CONFIG_CHARGE_MODE (7 << 10) // 3 bits for mode
56+
#define CONFIG_SERVICE_EMONCMS (1 << 0)
57+
#define CONFIG_SERVICE_MQTT (1 << 1)
58+
#define CONFIG_SERVICE_OHM (1 << 2)
59+
#define CONFIG_SERVICE_SNTP (1 << 3)
60+
#define CONFIG_MQTT_PROTOCOL (7 << 4) // Maybe leave a bit of space after for additional protocols
61+
#define CONFIG_MQTT_ALLOW_ANY_CERT (1 << 7)
62+
#define CONFIG_SERVICE_TESLA (1 << 8)
63+
#define CONFIG_SERVICE_DIVERT (1 << 9)
64+
#define CONFIG_CHARGE_MODE (7 << 10) // 3 bits for mode
65+
#define CONFIG_PAUSE_USES_DISABLED (1 << 13)
6566

6667
inline bool config_emoncms_enabled() {
6768
return CONFIG_SERVICE_EMONCMS == (flags & CONFIG_SERVICE_EMONCMS);
@@ -99,6 +100,10 @@ inline uint8_t config_charge_mode() {
99100
return (flags & CONFIG_CHARGE_MODE) >> 10;
100101
}
101102

103+
inline bool config_pause_uses_disabled() {
104+
return CONFIG_PAUSE_USES_DISABLED == (flags & CONFIG_PAUSE_USES_DISABLED);
105+
}
106+
102107
// Ohm Connect Settings
103108
extern String ohm;
104109

src/divert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void divertmode_update(byte newmode)
8787
}
8888
if(OPENEVSE_STATE_SLEEPING != state)
8989
{
90-
if(0 == rapiSender.sendCmdSync(F("$FS")))
90+
if(0 == rapiSender.sendCmdSync(config_pause_uses_disabled() ? F("$FD") : F("$FS")))
9191
{
9292
DBUGLN(F("Divert activated, entered sleep mode"));
9393
divert_active = false;
@@ -264,7 +264,7 @@ void divert_update_state()
264264
{
265265
if(divert_active && divertmode_get_time() >= min_charge_end)
266266
{
267-
if(0 == rapiSender.sendCmdSync(F("$FS")))
267+
if(0 == rapiSender.sendCmdSync(config_pause_uses_disabled() ? F("$FD") : F("$FS")))
268268
{
269269
DBUGLN(F("Charge Stopped"));
270270
event["divert_active"] = divert_active = false;

0 commit comments

Comments
 (0)