Skip to content

Commit 3de6858

Browse files
authored
Merge pull request #111 from OpenEVSE/disable_to_pause
Use the disable state to pause charge
2 parents 0a8f916 + 0012bee commit 3de6858

File tree

8 files changed

+40
-25
lines changed

8 files changed

+40
-25
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;

src/web_static/web_server.home.html.h

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/web_static/web_server.home.js.h

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/web_static/web_server.lib.js.h

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test.http

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ Content-Type: application/json
9292
POST {{baseUrl}}/config HTTP/1.1
9393
Content-Type: application/json
9494

95-
{
96-
"emoncms_enabled": false
97-
}
98-
99-
###
100-
101-
POST {{baseUrl}}/config HTTP/1.1
102-
Content-Type: application/json
103-
10495
{
10596
"mqtt_enabled": true,
10697
"mqtt_protocol": "mqtt",
@@ -144,6 +135,24 @@ Content-Type: application/json
144135

145136
###
146137

138+
POST {{baseUrl}}/config HTTP/1.1
139+
Content-Type: application/json
140+
141+
{
142+
"pause_uses_disabled": true
143+
}
144+
145+
###
146+
147+
POST {{baseUrl}}/config HTTP/1.1
148+
Content-Type: application/json
149+
150+
{
151+
"pause_uses_disabled": false
152+
}
153+
154+
###
155+
147156
GET {{baseUrl}}/home.js HTTP/1.1
148157

149158
###

0 commit comments

Comments
 (0)