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

Improve Solar divert logic #679

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "gui-v2"]
path = gui-v2
url = https://github.com/OpenEVSE/openevse-gui-v2
branch = master
url = https://github.com/larroy/openevse-gui-v2.git
branch = new_divert
2 changes: 1 addition & 1 deletion api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ paths:
divertmode: 1
solar: 390
grid_ie: 0
charge_rate: 7
divert_charge_current: 7
divert_update: 0
ota_update: 0
time: '2020-05-12T17:53:48Z'
Expand Down
7 changes: 5 additions & 2 deletions models/Config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ x-examples:
ocpp_authkey: ''
ohm: ''
divert_type: -1
divert_PV_ratio: 1.1
divert_reserve_power_w: 200
divert_hysteresis_power_w: 600
divert_attack_smoothing_time: 20
divert_decay_smoothing_time: 200
divert_min_charge_time: 600
Expand Down Expand Up @@ -265,7 +266,9 @@ properties:
type: string
divert_type:
type: number
divert_PV_ratio:
divert_reserve_power_w:
type: number
divert_hysteresis_power_w:
type: number
divert_attack_smoothing_time:
type: number
Expand Down
23 changes: 16 additions & 7 deletions models/Status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,33 @@ properties:
description: The current service level
minimum: 1
maximum: 2
solar:
divert_solar_w:
type: integer
description: The latest solar feed value received
grid_ie:
divert_solar_a:
type: integer
description: The latest solar feed value received in amps
divert_grid_ie_w:
type: integer
description: The latest grid +I/-E feed value received
charge_rate:
divert_grid_ie_a:
type: integer
description: The latest grid +I/-E feed value received in amps
divert_charge_current:
type: integer
description: The divert charge rate
trigger_current:
description: The divert target charge current
divert_trigger_current:
type: integer
description: The current at which the divert module will start the charge
available_current:
divert_available_current:
type: integer
description: The computed avalible current for divert
smoothed_available_current:
divert_smoothed_available_current:
type: integer
description: The computed smoothed available current for divert
divert_min_charge_time_rem_s:
type: integer
description: Minimum charge time remaining in seconds
divert_update:
type: number
description: The time since the last update of the divert feed
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ build_flags =
-D AO_CA_CERT_LOCAL ; manage certificate locally
#-D ENABLE_DEBUG
#-D ENABLE_DEBUG_MONGOOSE_HTTP_CLIENT
-D NO_SENSOR_SCALING=1
-D RAPI_MAX_COMMANDS=20
-D BUILD_ENV_NAME="$PIOENV"
-D ARDUINO_ARCH_ESP32
Expand Down
6 changes: 4 additions & 2 deletions src/app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ String ohm;

// Divert settings
int8_t divert_type;
double divert_PV_ratio;
int32_t divert_reserve_power_w;
int32_t divert_hysteresis_power_w;
uint32_t divert_attack_smoothing_time;
uint32_t divert_decay_smoothing_time;
uint32_t divert_min_charge_time;
Expand Down Expand Up @@ -190,7 +191,8 @@ ConfigOpt *opts[] =

// 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<int32_t>(divert_reserve_power_w, 100, "divert_reserve_power_w", "drp"),
new ConfigOptDefenition<int32_t>(divert_hysteresis_power_w, 300, "divert_hysteresis_power_w", "dhp"),
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"),
new ConfigOptDefenition<uint32_t>(divert_min_charge_time, 600, "divert_min_charge_time", "dt"),
Expand Down
3 changes: 2 additions & 1 deletion src/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ extern String time_zone;

// Divert settings
extern int8_t divert_type;
extern double divert_PV_ratio;
extern int32_t divert_reserve_power_w;
extern int32_t divert_hysteresis_power_w;
extern uint32_t divert_attack_smoothing_time;
extern uint32_t divert_decay_smoothing_time;
extern uint32_t divert_min_charge_time;
Expand Down
2 changes: 1 addition & 1 deletion src/current_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void CurrentShaperTask::shapeCurrent() {

if (config_divert_enabled() == true) {
if ( divert_type == DIVERT_TYPE_SOLAR ) {
max_pwr += solar;
max_pwr += divert_solar_w;
}
}
if (livepwr > max_pwr) {
Expand Down
Loading