Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New settings / flags (#595) #618

Merged
merged 36 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6f36c27
add new config properties: divert_type, wizard_passed (-1 unset, 0 so…
KipK Apr 5, 2023
f7a89e6
use divert_type instead of checking mqtt fields
KipK Apr 26, 2023
1195f69
added vehicle_data_src config prop
KipK Apr 27, 2023
0e7651f
trailing space
KipK May 1, 2023
0e1520a
default openevse to disabled state at boot
KipK May 1, 2023
eeb7555
new default_state flag
KipK May 2, 2023
6d46c44
use new divert_type in divert_sim
KipK May 2, 2023
8265edc
trailing mqtt_solar condition in current_shaper
KipK May 3, 2023
040132b
start EnergyMeter sooner to prevent divert_sim crash
KipK May 6, 2023
d77f20d
set AP SSID & PASS
KipK May 7, 2023
bfb7557
edited api.yml config.yaml
KipK May 9, 2023
62f258f
use enum instead of #define
KipK May 9, 2023
3ef63d5
changed bootlock handling
KipK May 10, 2023
b4c0cd0
bump openevse lib version
KipK May 13, 2023
6266db6
added /restartevse endpoint + added payload to mqtt /restart => /rest…
KipK May 15, 2023
cfaab5a
put back unlock openevse to evseBoot
KipK May 15, 2023
cd0ae07
enum divert_type rename
KipK May 16, 2023
b6da9e7
changed http api & mqtt /restart {"device": "gateway|evse"}
KipK May 16, 2023
01fa11b
added doc
KipK May 16, 2023
c51a12b
update gui
KipK May 16, 2023
41e3967
fix bootlock unlock missed in some conditions
KipK May 18, 2023
ff0f69e
add missing evse_connected property in create_rapi_json ( connection …
KipK May 18, 2023
d3a9177
Adding write permission to PRs
jeremypoulter May 18, 2023
3cb80e3
Attempt 2 to fix permissions issue
jeremypoulter May 18, 2023
065e4eb
More permissions changes
jeremypoulter May 19, 2023
e1791c3
Trying all permissions
jeremypoulter May 19, 2023
01be5ba
Not apermission issue we can solve here :(
jeremypoulter May 19, 2023
5e66081
indent api.yml
KipK May 21, 2023
f63be11
Merge branch 'newflags' of https://github.com/KipK/ESP32_WiFi_V4.x in…
KipK May 21, 2023
0769da8
update static files
KipK May 21, 2023
566cd4e
fix mqtt doc #650
KipK May 21, 2023
31a1776
fix api.yml
KipK May 21, 2023
fa212aa
Revert "update static files"
KipK May 21, 2023
94cef5a
cleanup static files
KipK May 21, 2023
246c42c
Merge branch 'master' into newflags
KipK May 21, 2023
57b0c93
updated gui statics
KipK May 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ paths:
emoncms_fingerprint: ''
Configure Solar divert:
value:
divert_type: 0
divert_enabled: true
divert_attack_smoothing_time: 8
divert_decay_smoothing_time: 300
Expand Down Expand Up @@ -529,6 +530,33 @@ paths:
name: index
in: path
required: true
/restart:
post:
summary: restart gateway or evse modules
description: restart wifi gateway or openevse module
operationId: restart
tags:
- Restart
requestBody:
content:
application/json:
schema:
type: object
properties:
device:
type: string
description: gateway|evse
responses:
'200':
description: Restart successfull
content:
application/json:
schema:
type: object
properties:
msg:
type: string
description: restart gateway|evse
/limit:
get:
summary: Get charge limit
Expand Down Expand Up @@ -930,3 +958,4 @@ tags:
- name: Limit
- name: Energy Meter
- name: Time
- name: Restart
5 changes: 2 additions & 3 deletions divert_sim/divert_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ int main(int argc, char** argv)

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

mqtt_solar = grid_ie_col >= 0 ? "" : "yes";
mqtt_grid_ie = grid_ie_col >= 0 ? "yes" : "";

divert_type = grid_ie_col >= 0 ? 1 : 0;

if(voltage_arg >= 0) {
if(voltage_arg < 50) {
voltage_col = voltage_arg;
Expand Down
10 changes: 5 additions & 5 deletions docs/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Claim & override properties can be set independantly. Sending json with only som
To remove a selected claim/override property, just send "clear" as property parameter ( i.e. `<base-topic>/claim/set {"charge_current": "clear"}` )

Scheduler data:
`<base-topic>/scheduler/` : get scheduler data ([json data]
`<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 )
`<base-topic>/scheduler/clear <id> :`remove related event
`<base-topic>/schedule/` : get scheduler data ([json data]
`<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 )
`<base-topic>/schedule/clear <id> :`remove related event

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

Main settings:

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



Expand Down
35 changes: 34 additions & 1 deletion models/Config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ x-examples:
- https
ssid: wibble_ext
pass: _DUMMY_PASSWORD
ap_ssid: openevse-2343
ap_pass: _DUMMY_PASSWORD
lang: en
www_username: ''
www_password: ''
Expand Down Expand Up @@ -58,6 +60,7 @@ x-examples:
ocpp_chargeBoxId: ''
ocpp_authkey: ''
ohm: ''
divert_type: -1
divert_PV_ratio: 1.1
divert_attack_smoothing_time: 20
divert_decay_smoothing_time: 200
Expand All @@ -66,12 +69,14 @@ x-examples:
current_shaper_min_pause_time: 300
current_shaper_data_maxinterval: 120
current_shaper_smoothing_time: 60
vehicle_data_src: 0
tesla_access_token: _DUMMY_PASSWORD
tesla_refresh_token: _DUMMY_PASSWORD
tesla_created_at: 2479357952
tesla_expires_in: 3888000
tesla_vehicle_id: '142960157278'
led_brightness: 51
scheduler_start_window: 60
flags: 115467
emoncms_enabled: true
mqtt_enabled: true
Expand All @@ -89,9 +94,12 @@ x-examples:
ocpp_auth_auto: true
ocpp_idtag: '0E000000'
ocpp_auth_offline: true
rfid_enabled: false
mqtt_protocol: mqtt
charge_mode: fast
is_threephase: false
wizard_passed: false
default_state: false
charge_mode: fast
x-tags:
- Config
properties:
Expand Down Expand Up @@ -170,6 +178,12 @@ properties:
pass:
type: string
minLength: 1
ap_ssid:
type: string
minLength: 1
ap_pass:
type: string
minLength: 1
www_username:
type: string
www_password:
Expand Down Expand Up @@ -245,8 +259,12 @@ properties:
type: string
ocpp_auth_offline:
type: boolean
rfid_enabled:
type: boolean
ohm:
type: string
divert_type:
type: number
divert_PV_ratio:
type: number
divert_attack_smoothing_time:
Expand All @@ -255,6 +273,10 @@ properties:
type: number
divert_min_charge_time:
type: number
current_shaper_max_pwr:
type: number
vehicle_data_src:
type: number
tesla_access_token:
type: string
minLength: 1
Expand Down Expand Up @@ -309,3 +331,14 @@ properties:
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.
is_threephase:
type: boolean
description: |
Needs to be enabled if charging with 3 phases setup for proper calculations
wizard_passed:
type: boolean
description: |
define if wizard has been passed or not
default_state:
type: boolean
description: |
OpenEVSE default state when no claims are running ( 0: disabled | 1: active)

2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ lib_deps =
jeremypoulter/[email protected]
jeremypoulter/Micro [email protected]
jeremypoulter/[email protected]
jeremypoulter/[email protected].13
jeremypoulter/[email protected].14
jeremypoulter/[email protected]
jeremypoulter/[email protected]
jeremypoulter/[email protected]
Expand Down
14 changes: 14 additions & 0 deletions src/app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
// Wifi Network Strings
String esid;
String epass;
String ap_ssid;
String ap_pass;

// Language
String lang;
Expand Down Expand Up @@ -87,6 +89,7 @@ uint32_t flags;
String ohm;

// Divert settings
int8_t divert_type;
double divert_PV_ratio;
uint32_t divert_attack_smoothing_time;
uint32_t divert_decay_smoothing_time;
Expand All @@ -106,6 +109,9 @@ uint64_t tesla_expires_in;

String tesla_vehicle_id;

// Vehicle
uint8_t vehicle_data_src;

#if RGB_LED
uint8_t led_brightness;
#endif
Expand All @@ -129,6 +135,8 @@ ConfigOpt *opts[] =
// Wifi Network Strings
new ConfigOptDefenition<String>(esid, "", "ssid", "ws"),
new ConfigOptSecret(epass, "", "pass", "wp"),
new ConfigOptDefenition<String>(ap_ssid, "", "ap_ssid", "as"),
new ConfigOptSecret(ap_pass, "", "ap_pass", "ap"),

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

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

// Vehicle settings
new ConfigOptDefenition<uint8_t>(vehicle_data_src, 0, "vehicle_data_src", "vds"),

// Tesla client settings
new ConfigOptSecret(tesla_access_token, "", "tesla_access_token", "tat"),
new ConfigOptSecret(tesla_refresh_token, "", "tesla_refresh_token", "trt"),
Expand Down Expand Up @@ -231,6 +243,8 @@ ConfigOpt *opts[] =
new ConfigOptVirtualBool(flagsOpt, CONFIG_RFID, CONFIG_RFID, "rfid_enabled", "rf"),
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")};

Expand Down
32 changes: 26 additions & 6 deletions src/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include "evse_state.h"

#ifndef ENABLE_CONFIG_V1_IMPORT
#define ENABLE_CONFIG_V1_IMPORT 1
Expand All @@ -23,7 +24,8 @@
// Wifi Network Strings
extern String esid;
extern String epass;

extern String ap_ssid;
extern String ap_pass;
// Language
extern String lang;

Expand Down Expand Up @@ -74,6 +76,7 @@ extern String rfid_storage;
extern String time_zone;

// Divert settings
extern int8_t divert_type;
extern double divert_PV_ratio;
extern uint32_t divert_attack_smoothing_time;
extern uint32_t divert_decay_smoothing_time;
Expand All @@ -88,6 +91,16 @@ extern uint32_t current_shaper_smoothing_time;
extern uint32_t current_shaper_min_pause_time;
extern uint32_t current_shaper_data_maxinterval;

// Vehicle
extern uint8_t vehicle_data_src;

enum vehicle_data_src {
VEHICLE_DATA_SRC_NONE,
VEHICLE_DATA_SRC_TESLA,
VEHICLE_DATA_SRC_MQTT,
VEHICLE_DATA_SRC_HTTP
};

// 24-bits of Flags
extern uint32_t flags;

Expand All @@ -112,7 +125,8 @@ extern uint32_t flags;
#define CONFIG_OCPP_AUTO_AUTH (1 << 22)
#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);
Expand Down Expand Up @@ -162,10 +176,6 @@ inline bool config_ocpp_offline_authorization() {
return CONFIG_OCPP_OFFLINE_AUTH == (flags & CONFIG_OCPP_OFFLINE_AUTH);
}

inline bool config_tesla_enabled() {
return CONFIG_SERVICE_TESLA == (flags & CONFIG_SERVICE_TESLA);
}

inline bool config_divert_enabled() {
return CONFIG_SERVICE_DIVERT == (flags & CONFIG_SERVICE_DIVERT);
}
Expand Down Expand Up @@ -198,6 +208,16 @@ inline bool config_threephase_enabled() {
return CONFIG_THREEPHASE == (flags & CONFIG_THREEPHASE);
}

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;

Expand Down
7 changes: 4 additions & 3 deletions src/current_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ unsigned long CurrentShaperTask::loop(MicroTasks::WakeReason reason) {
}
}


return EVSE_SHAPER_LOOP_TIME;
}

Expand Down Expand Up @@ -137,7 +136,7 @@ void CurrentShaperTask::setLivePwr(int live_pwr) {
shapeCurrent();
}

// temporary change Current Shaper state without changing configuration
// temporary change Current Shaper state without changing configuration
void CurrentShaperTask::setState(bool state) {
_enabled = state;
if (!_enabled) {
Expand Down Expand Up @@ -171,7 +170,7 @@ void CurrentShaperTask::shapeCurrent() {
}

if (config_divert_enabled() == true) {
if (mqtt_solar != "") {
if ( divert_type == DIVERT_TYPE_SOLAR ) {
max_pwr += solar;
}
}
Expand All @@ -186,6 +185,8 @@ void CurrentShaperTask::shapeCurrent() {
_max_cur = ((max_pwr - livepwr) / evse.getVoltage() / 3.0) + evse.getAmps();
}



_changed = true;
}

Expand Down
Loading