Skip to content

Commit c59fd8f

Browse files
authored
Merge pull request #296 from OpenEVSE/jeremypoulter/issue140
Updating the firmware to handle configuring the EVSE
2 parents 395ad66 + b2475ff commit c59fd8f

24 files changed

+672
-167
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
- openevse_esp32-heltec-wifi-lora-v2
2727

2828
steps:
29+
- uses: ammaraskar/gcc-problem-matcher@master
30+
2931
- uses: actions/checkout@v2
3032
with:
3133
submodules: recursive
@@ -114,4 +116,3 @@ jobs:
114116
title: "Development Build"
115117
files: |
116118
*.bin
117-

api.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,4 @@ tags:
641641
- name: Manual Override
642642
- name: Schedule
643643
- name: Status
644+
- name: Tesla

models/Config.yaml

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ x-examples:
88
espinfo: ESP32r1 2 core WiFi BLE BT
99
buildenv: openevse_esp-wrover-kit
1010
version: 4.1.0.dev
11-
diodet: 0
12-
gfcit: 0
13-
groundt: 1
14-
relayt: 0
15-
ventt: 0
16-
tempt: 1
11+
diode_check: true
12+
gfci_check: true
13+
ground_check: true
14+
relay_check: true
15+
vent_check: true
16+
temp_check: true
1717
service: 0
1818
scale: 220
1919
offset: 0
20+
max_current_soft: 32
21+
min_current_hard: 6
22+
max_current_hard: 32
2023
mqtt_supported_protocols:
2124
- mqtt
2225
- mqtts
@@ -83,15 +86,18 @@ examples:
8386
espinfo: ESP32r1 2 core WiFi BLE BT
8487
buildenv: openevse_esp-wrover-kit
8588
version: 4.1.0.dev
86-
diodet: 0
87-
gfcit: 0
88-
groundt: 1
89-
relayt: 0
90-
ventt: 0
91-
tempt: 1
89+
diode_check: true
90+
gfci_check: true
91+
ground_check: true
92+
relay_check: true
93+
vent_check: true
94+
temp_check: true
9295
service: 0
9396
scale: 220
9497
offset: 0
98+
max_current_soft: 32
99+
min_current_hard: 6
100+
max_current_hard: 32
95101
mqtt_supported_protocols:
96102
- mqtt
97103
- mqtts
@@ -151,6 +157,8 @@ examples:
151157
ocpp_energize_plug: true
152158
mqtt_protocol: mqtt
153159
charge_mode: fast
160+
x-tags:
161+
- Config
154162
properties:
155163
firmware:
156164
type: string
@@ -175,32 +183,33 @@ properties:
175183
type: string
176184
minLength: 1
177185
readOnly: true
178-
diodet:
179-
type: number
180-
readOnly: true
181-
gfcit:
182-
type: number
183-
readOnly: true
184-
groundt:
185-
type: number
186-
readOnly: true
187-
relayt:
188-
type: number
189-
readOnly: true
190-
ventt:
191-
type: number
192-
readOnly: true
193-
tempt:
194-
type: number
195-
readOnly: true
186+
diode_check:
187+
type: boolean
188+
gfci_check:
189+
type: boolean
190+
ground_check:
191+
type: boolean
192+
relay_check:
193+
type: boolean
194+
vent_check:
195+
type: boolean
196+
temp_check:
197+
type: boolean
196198
service:
197-
type: number
198-
readOnly: true
199+
type: integer
200+
minimum: 0
201+
maximum: 2
199202
scale:
200-
type: number
201-
readOnly: true
203+
type: integer
202204
offset:
203-
type: number
205+
type: integer
206+
max_current_soft:
207+
type: integer
208+
min_current_hard:
209+
type: integer
210+
readOnly: true
211+
max_current_hard:
212+
type: integer
204213
readOnly: true
205214
mqtt_supported_protocols:
206215
type: array
@@ -254,7 +263,7 @@ properties:
254263
type: string
255264
minLength: 1
256265
mqtt_port:
257-
type: number
266+
type: integer
258267
mqtt_topic:
259268
type: string
260269
minLength: 1
@@ -347,5 +356,3 @@ properties:
347356
charge_mode:
348357
type: string
349358
minLength: 1
350-
x-tags:
351-
- Config

models/EvseState.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ enum:
66
x-tags:
77
- Claims
88
- Status
9+
description: Either enable charging (`active`) or block charging (`disabled`)

models/Properties.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,37 @@ type: object
33
x-tags:
44
- Claims
55
description: ''
6+
examples: []
67
properties:
78
state:
89
$ref: ./EvseState.yaml
910
charge_current:
1011
type: integer
1112
minimum: 0
13+
description: Specify the active charge current in Amps
1214
max_current:
1315
type: integer
1416
minimum: 0
17+
description: Dynamically alter the max current while still allowing other claims to very the current via `charge_current` that can not exceede this value. This is primerialy designed for load sharing situations while still allowing things like PV divert to work so the charge current is the minimum of `charge_current` <= `max_current` <= configured soft limit <= hard coded limit
1518
energy_limit:
1619
type: integer
1720
minimum: 0
21+
format: int32
22+
description: |-
23+
Stop the charge after `energy_limit` Wh of energy have been transfered.
24+
25+
> Note: Not currently implemented
1826
time_limit:
1927
type: integer
2028
minimum: 0
29+
format: int32
30+
description: |-
31+
Stop the charge after the duration of the charging session has exceeded `time_limit` seconds
32+
33+
> Note: Not currently implemented
2134
auto_release:
2235
type: boolean
2336
description: |
2437
`true` if the manual override is auto-released when the vehicle is
2538
disconnected, `false` if manual override will persist after vehicle
2639
disconnection.
27-
examples: []

models/Status.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ properties:
116116
divertmode:
117117
type: integer
118118
description: 'The PV divert mode, `1` normal, `2` Eco'
119+
service_level:
120+
type: integer
121+
description: The current service level
122+
minimum: 1
123+
maximum: 2
119124
solar:
120125
type: integer
121126
description: The latest solar feed value received

platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ lib_deps =
3535
3636
jeremypoulter/[email protected]
3737
jeremypoulter/Micro [email protected]
38-
jeremypoulter/[email protected].3
38+
jeremypoulter/[email protected].4
3939
jeremypoulter/[email protected]
4040
jeremypoulter/[email protected]
4141
jeremypoulter/[email protected]
@@ -283,12 +283,12 @@ board_build.partitions = ${common.build_partitions}
283283
#https://github.com/OpenEVSE/ESP32_WiFi_V3.x/blob/master/docs/wired-ethernet.md
284284
extends = env:openevse_esp32-gateway
285285
framework = arduino, espidf
286-
upload_speed = 921600
287286
build_flags =
288287
${common.build_flags}
289288
-D RX2=16
290289
-D TX2=32
291290
board_build.extra_flags = "-DARDUINO_ESP32_GATEWAY=\'E\'"
291+
upload_speed = 921600
292292

293293
[env:openevse_esp32-heltec-wifi-lora-v2]
294294
platform = ${common.platform}

src/app_config.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ String tesla_vehicle_id;
8484
uint8_t led_brightness;
8585
#endif
8686

87+
long max_current_soft;
88+
8789
String esp_hostname_default = "openevse-"+ESPAL.getShortId();
8890

8991
void config_changed(String name);
@@ -154,6 +156,9 @@ ConfigOpt *opts[] =
154156
new ConfigOptDefenition<uint8_t>(led_brightness, LED_DEFAULT_BRIGHTNESS, "led_brightness", "lb"),
155157
#endif
156158

159+
// EVSE settings
160+
new ConfigOptDefenition<long>(max_current_soft, LONG_MAX, "max_current_soft", "mcs"),
161+
157162
// Flags
158163
&flagsOpt,
159164

@@ -238,6 +243,8 @@ void config_changed(String name)
238243
} else if(name == "led_brightness") {
239244
ledManager.setBrightness(led_brightness);
240245
#endif
246+
} else if(name == "max_current_soft") {
247+
evse.setMaxConfiguredCurrent(max_current_soft);
241248
}
242249
}
243250

src/evse_man.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ EvseManager::EvseManager(Stream &port, EventLog &eventLog) :
139139
_eventLog(eventLog),
140140
_clients(),
141141
_evseStateListener(this),
142+
_evseBootListener(this),
142143
_sessionCompleteListener(this),
143144
_targetProperties(EvseState::Active),
144145
_hasClaims(false),
@@ -251,6 +252,7 @@ bool EvseManager::evaluateClaims(EvseProperties &properties)
251252

252253
void EvseManager::setup()
253254
{
255+
_monitor.onBootReady(&_evseBootListener);
254256
_monitor.onStateChange(&_evseStateListener);
255257
_monitor.onSessionComplete(&_sessionCompleteListener);
256258
}
@@ -335,6 +337,11 @@ unsigned long EvseManager::loop(MicroTasks::WakeReason reason)
335337
return 10 * 1000;
336338
}
337339

340+
DBUGVAR(_evseBootListener.IsTriggered());
341+
if(_evseBootListener.IsTriggered()) {
342+
_evaluateTargetState = true;
343+
}
344+
338345
DBUGVAR(_evseStateListener.IsTriggered());
339346
if(_evseStateListener.IsTriggered())
340347
{
@@ -584,6 +591,16 @@ void EvseManager::setVehicleEta(int vehicleEta)
584591
MicroTask.wakeTask(this);
585592
}
586593

594+
void EvseManager::setMaxConfiguredCurrent(long amps)
595+
{
596+
_monitor.setMaxConfiguredCurrent(amps);
597+
DBUGF("Max configured current set to %ld", _monitor.getMaxConfiguredCurrent());
598+
// Setting the Max Current will update the pilot as well, but in any case we may
599+
// need to change the level so re-evaluate the claims
600+
_evaluateClaims = true;
601+
MicroTask.wakeTask(this);
602+
}
603+
587604
bool EvseManager::isRapiCommandBlocked(String rapi)
588605
{
589606
return rapi.startsWith("$ST");

0 commit comments

Comments
 (0)