Skip to content

Commit beb2a21

Browse files
Merge pull request #618 from KipK/newflags
New settings / flags (#595)
2 parents 8ce9db4 + 57b0c93 commit beb2a21

37 files changed

+10132
-9800
lines changed

api.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ paths:
191191
emoncms_fingerprint: ''
192192
Configure Solar divert:
193193
value:
194+
divert_type: 0
194195
divert_enabled: true
195196
divert_attack_smoothing_time: 8
196197
divert_decay_smoothing_time: 300
@@ -529,6 +530,33 @@ paths:
529530
name: index
530531
in: path
531532
required: true
533+
/restart:
534+
post:
535+
summary: restart gateway or evse modules
536+
description: restart wifi gateway or openevse module
537+
operationId: restart
538+
tags:
539+
- Restart
540+
requestBody:
541+
content:
542+
application/json:
543+
schema:
544+
type: object
545+
properties:
546+
device:
547+
type: string
548+
description: gateway|evse
549+
responses:
550+
'200':
551+
description: Restart successfull
552+
content:
553+
application/json:
554+
schema:
555+
type: object
556+
properties:
557+
msg:
558+
type: string
559+
description: restart gateway|evse
532560
/limit:
533561
get:
534562
summary: Get charge limit
@@ -930,3 +958,4 @@ tags:
930958
- name: Limit
931959
- name: Energy Meter
932960
- name: Time
961+
- name: Restart

divert_sim/divert_sim.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ int main(int argc, char** argv)
143143

144144
kw = result.count("kw") > 0;
145145

146-
mqtt_solar = grid_ie_col >= 0 ? "" : "yes";
147-
mqtt_grid_ie = grid_ie_col >= 0 ? "yes" : "";
148-
146+
divert_type = grid_ie_col >= 0 ? 1 : 0;
147+
149148
if(voltage_arg >= 0) {
150149
if(voltage_arg < 50) {
151150
voltage_col = voltage_arg;

docs/mqtt.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Claim & override properties can be set independantly. Sending json with only som
4040
To remove a selected claim/override property, just send "clear" as property parameter ( i.e. `<base-topic>/claim/set {"charge_current": "clear"}` )
4141

4242
Scheduler data:
43-
`<base-topic>/scheduler/` : get scheduler data ([json data]
44-
`<base-topic>/scheduler/set <json data>` : set/update schedules ( data as refered from API: https://openevse.stoplight.io/docs/openevse-wifi-v4/e87e6f3f90787-batch-update-schedule )
45-
`<base-topic>/scheduler/clear <id> :`remove related event
43+
`<base-topic>/schedule/` : get scheduler data ([json data]
44+
`<base-topic>/schedule/set <json data>` : set/update schedules ( data as refered from API: https://openevse.stoplight.io/docs/openevse-wifi-v4/e87e6f3f90787-batch-update-schedule )
45+
`<base-topic>/schedule/clear <id> :`remove related event
4646

4747
Limit:
4848
`<base-topic>/limit/` : get limit data ([json data]
@@ -51,9 +51,9 @@ Limit:
5151

5252
Main settings:
5353

54-
`<base-topic>/divertmode/set [1 | 2]` : enable (1)/ disable (2) divert mode
54+
`<base-topic>/divertmode/set [1 | 2]` : enable (1)/ disable (2) divert mode
5555
`<base-topic>/shaper/set [0 | 1]` : temporary enable (1)/ disable (0) current shaper ( doesn't survive reboot )
56-
`<base-topic>/restart` : restarts the gateway
56+
`<base-topic>/restart {"device": "gateway|evse"}` : restart the gateway or openevse module
5757

5858

5959

models/Config.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ x-examples:
2828
- https
2929
ssid: wibble_ext
3030
pass: _DUMMY_PASSWORD
31+
ap_ssid: openevse-2343
32+
ap_pass: _DUMMY_PASSWORD
3133
lang: en
3234
www_username: ''
3335
www_password: ''
@@ -58,6 +60,7 @@ x-examples:
5860
ocpp_chargeBoxId: ''
5961
ocpp_authkey: ''
6062
ohm: ''
63+
divert_type: -1
6164
divert_PV_ratio: 1.1
6265
divert_attack_smoothing_time: 20
6366
divert_decay_smoothing_time: 200
@@ -66,12 +69,14 @@ x-examples:
6669
current_shaper_min_pause_time: 300
6770
current_shaper_data_maxinterval: 120
6871
current_shaper_smoothing_time: 60
72+
vehicle_data_src: 0
6973
tesla_access_token: _DUMMY_PASSWORD
7074
tesla_refresh_token: _DUMMY_PASSWORD
7175
tesla_created_at: 2479357952
7276
tesla_expires_in: 3888000
7377
tesla_vehicle_id: '142960157278'
7478
led_brightness: 51
79+
scheduler_start_window: 60
7580
flags: 115467
7681
emoncms_enabled: true
7782
mqtt_enabled: true
@@ -89,9 +94,12 @@ x-examples:
8994
ocpp_auth_auto: true
9095
ocpp_idtag: '0E000000'
9196
ocpp_auth_offline: true
97+
rfid_enabled: false
9298
mqtt_protocol: mqtt
93-
charge_mode: fast
9499
is_threephase: false
100+
wizard_passed: false
101+
default_state: false
102+
charge_mode: fast
95103
x-tags:
96104
- Config
97105
properties:
@@ -170,6 +178,12 @@ properties:
170178
pass:
171179
type: string
172180
minLength: 1
181+
ap_ssid:
182+
type: string
183+
minLength: 1
184+
ap_pass:
185+
type: string
186+
minLength: 1
173187
www_username:
174188
type: string
175189
www_password:
@@ -245,8 +259,12 @@ properties:
245259
type: string
246260
ocpp_auth_offline:
247261
type: boolean
262+
rfid_enabled:
263+
type: boolean
248264
ohm:
249265
type: string
266+
divert_type:
267+
type: number
250268
divert_PV_ratio:
251269
type: number
252270
divert_attack_smoothing_time:
@@ -255,6 +273,10 @@ properties:
255273
type: number
256274
divert_min_charge_time:
257275
type: number
276+
current_shaper_max_pwr:
277+
type: number
278+
vehicle_data_src:
279+
type: number
258280
tesla_access_token:
259281
type: string
260282
minLength: 1
@@ -309,3 +331,14 @@ properties:
309331
The maximum number of seconds to randomly add/subtract from the a scheduled charge start time, eg a value of 600 will adjust the start time my +/- 10 minutes. This is to help prevent large syncrinised loads when multiple verchiles start charging at the same time.
310332
is_threephase:
311333
type: boolean
334+
description: |
335+
Needs to be enabled if charging with 3 phases setup for proper calculations
336+
wizard_passed:
337+
type: boolean
338+
description: |
339+
define if wizard has been passed or not
340+
default_state:
341+
type: boolean
342+
description: |
343+
OpenEVSE default state when no claims are running ( 0: disabled | 1: active)
344+

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ lib_deps =
3434
jeremypoulter/[email protected]
3535
jeremypoulter/Micro [email protected]
3636
jeremypoulter/[email protected]
37-
jeremypoulter/[email protected].13
37+
jeremypoulter/[email protected].14
3838
jeremypoulter/[email protected]
3939
jeremypoulter/[email protected]
4040
jeremypoulter/[email protected]

src/app_config.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
// Wifi Network Strings
3535
String esid;
3636
String epass;
37+
String ap_ssid;
38+
String ap_pass;
3739

3840
// Language
3941
String lang;
@@ -87,6 +89,7 @@ uint32_t flags;
8789
String ohm;
8890

8991
// Divert settings
92+
int8_t divert_type;
9093
double divert_PV_ratio;
9194
uint32_t divert_attack_smoothing_time;
9295
uint32_t divert_decay_smoothing_time;
@@ -106,6 +109,9 @@ uint64_t tesla_expires_in;
106109

107110
String tesla_vehicle_id;
108111

112+
// Vehicle
113+
uint8_t vehicle_data_src;
114+
109115
#if RGB_LED
110116
uint8_t led_brightness;
111117
#endif
@@ -129,6 +135,8 @@ ConfigOpt *opts[] =
129135
// Wifi Network Strings
130136
new ConfigOptDefenition<String>(esid, "", "ssid", "ws"),
131137
new ConfigOptSecret(epass, "", "pass", "wp"),
138+
new ConfigOptDefenition<String>(ap_ssid, "", "ap_ssid", "as"),
139+
new ConfigOptSecret(ap_pass, "", "ap_pass", "ap"),
132140

133141
// Language String
134142
new ConfigOptDefenition<String>(lang, "", "lang", "lan"),
@@ -179,6 +187,7 @@ ConfigOpt *opts[] =
179187
new ConfigOptDefenition<String>(ohm, "", "ohm", "o"),
180188

181189
// Divert settings
190+
new ConfigOptDefenition<int8_t>(divert_type, -1, "divert_type", "dm"),
182191
new ConfigOptDefenition<double>(divert_PV_ratio, 1.1, "divert_PV_ratio", "dpr"),
183192
new ConfigOptDefenition<uint32_t>(divert_attack_smoothing_time, 20, "divert_attack_smoothing_time", "das"),
184193
new ConfigOptDefenition<uint32_t>(divert_decay_smoothing_time, 600, "divert_decay_smoothing_time", "dds"),
@@ -190,6 +199,9 @@ ConfigOpt *opts[] =
190199
new ConfigOptDefenition<uint32_t>(current_shaper_min_pause_time, 300, "current_shaper_min_pause_time", "spt"),
191200
new ConfigOptDefenition<uint32_t>(current_shaper_data_maxinterval, 120, "current_shaper_data_maxinterval", "sdm"),
192201

202+
// Vehicle settings
203+
new ConfigOptDefenition<uint8_t>(vehicle_data_src, 0, "vehicle_data_src", "vds"),
204+
193205
// Tesla client settings
194206
new ConfigOptSecret(tesla_access_token, "", "tesla_access_token", "tat"),
195207
new ConfigOptSecret(tesla_refresh_token, "", "tesla_refresh_token", "trt"),
@@ -231,6 +243,8 @@ ConfigOpt *opts[] =
231243
new ConfigOptVirtualBool(flagsOpt, CONFIG_RFID, CONFIG_RFID, "rfid_enabled", "rf"),
232244
new ConfigOptVirtualBool(flagsOpt, CONFIG_FACTORY_WRITE_LOCK, CONFIG_FACTORY_WRITE_LOCK, "factory_write_lock", "fwl"),
233245
new ConfigOptVirtualBool(flagsOpt, CONFIG_THREEPHASE, CONFIG_THREEPHASE, "is_threephase", "itp"),
246+
new ConfigOptVirtualBool(flagsOpt, CONFIG_WIZARD, CONFIG_WIZARD, "wizard_passed", "wzp"),
247+
new ConfigOptVirtualBool(flagsOpt, CONFIG_DEFAULT_STATE, CONFIG_DEFAULT_STATE, "default_state", "dfs"),
234248
new ConfigOptVirtualMqttProtocol(flagsOpt, "mqtt_protocol", "mprt"),
235249
new ConfigOptVirtualChargeMode(flagsOpt, "charge_mode", "chmd")};
236250

src/app_config.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <Arduino.h>
55
#include <ArduinoJson.h>
6+
#include "evse_state.h"
67

78
#ifndef ENABLE_CONFIG_V1_IMPORT
89
#define ENABLE_CONFIG_V1_IMPORT 1
@@ -23,7 +24,8 @@
2324
// Wifi Network Strings
2425
extern String esid;
2526
extern String epass;
26-
27+
extern String ap_ssid;
28+
extern String ap_pass;
2729
// Language
2830
extern String lang;
2931

@@ -74,6 +76,7 @@ extern String rfid_storage;
7476
extern String time_zone;
7577

7678
// Divert settings
79+
extern int8_t divert_type;
7780
extern double divert_PV_ratio;
7881
extern uint32_t divert_attack_smoothing_time;
7982
extern uint32_t divert_decay_smoothing_time;
@@ -88,6 +91,16 @@ extern uint32_t current_shaper_smoothing_time;
8891
extern uint32_t current_shaper_min_pause_time;
8992
extern uint32_t current_shaper_data_maxinterval;
9093

94+
// Vehicle
95+
extern uint8_t vehicle_data_src;
96+
97+
enum vehicle_data_src {
98+
VEHICLE_DATA_SRC_NONE,
99+
VEHICLE_DATA_SRC_TESLA,
100+
VEHICLE_DATA_SRC_MQTT,
101+
VEHICLE_DATA_SRC_HTTP
102+
};
103+
91104
// 24-bits of Flags
92105
extern uint32_t flags;
93106

@@ -112,7 +125,8 @@ extern uint32_t flags;
112125
#define CONFIG_OCPP_AUTO_AUTH (1 << 22)
113126
#define CONFIG_OCPP_OFFLINE_AUTH (1 << 23)
114127
#define CONFIG_THREEPHASE (1 << 24)
115-
128+
#define CONFIG_WIZARD (1 << 25)
129+
#define CONFIG_DEFAULT_STATE (1 << 26)
116130

117131
inline bool config_emoncms_enabled() {
118132
return CONFIG_SERVICE_EMONCMS == (flags & CONFIG_SERVICE_EMONCMS);
@@ -162,10 +176,6 @@ inline bool config_ocpp_offline_authorization() {
162176
return CONFIG_OCPP_OFFLINE_AUTH == (flags & CONFIG_OCPP_OFFLINE_AUTH);
163177
}
164178

165-
inline bool config_tesla_enabled() {
166-
return CONFIG_SERVICE_TESLA == (flags & CONFIG_SERVICE_TESLA);
167-
}
168-
169179
inline bool config_divert_enabled() {
170180
return CONFIG_SERVICE_DIVERT == (flags & CONFIG_SERVICE_DIVERT);
171181
}
@@ -198,6 +208,16 @@ inline bool config_threephase_enabled() {
198208
return CONFIG_THREEPHASE == (flags & CONFIG_THREEPHASE);
199209
}
200210

211+
inline bool config_wizard_passed()
212+
{
213+
return CONFIG_WIZARD == (flags & CONFIG_WIZARD);
214+
}
215+
216+
inline EvseState config_default_state()
217+
{
218+
return CONFIG_DEFAULT_STATE == (flags & CONFIG_DEFAULT_STATE) ? EvseState::Active : EvseState::Disabled;
219+
}
220+
201221
// Ohm Connect Settings
202222
extern String ohm;
203223

src/current_shaper.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ unsigned long CurrentShaperTask::loop(MicroTasks::WakeReason reason) {
9797
}
9898
}
9999

100-
101100
return EVSE_SHAPER_LOOP_TIME;
102101
}
103102

@@ -137,7 +136,7 @@ void CurrentShaperTask::setLivePwr(int live_pwr) {
137136
shapeCurrent();
138137
}
139138

140-
// temporary change Current Shaper state without changing configuration
139+
// temporary change Current Shaper state without changing configuration
141140
void CurrentShaperTask::setState(bool state) {
142141
_enabled = state;
143142
if (!_enabled) {
@@ -171,7 +170,7 @@ void CurrentShaperTask::shapeCurrent() {
171170
}
172171

173172
if (config_divert_enabled() == true) {
174-
if (mqtt_solar != "") {
173+
if ( divert_type == DIVERT_TYPE_SOLAR ) {
175174
max_pwr += solar;
176175
}
177176
}
@@ -186,6 +185,8 @@ void CurrentShaperTask::shapeCurrent() {
186185
_max_cur = ((max_pwr - livepwr) / evse.getVoltage() / 3.0) + evse.getAmps();
187186
}
188187

188+
189+
189190
_changed = true;
190191
}
191192

0 commit comments

Comments
 (0)