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

Allow shaper to use same topic as grid_ie #551

Merged
merged 2 commits into from
Feb 25, 2023
Merged
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
11 changes: 6 additions & 5 deletions src/current_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ void CurrentShaperTask::shapeCurrent() {
if (mqtt_solar != "") {
max_pwr += solar;
}
else if (mqtt_grid_ie != "" && (grid_ie <= 0)) {
max_pwr -= grid_ie;
}
}
if(!config_threephase_enabled())
if(!config_threephase_enabled()) {
_max_cur = round(((max_pwr - _live_pwr) / evse.getVoltage()) + (evse.getAmps()));
else
}

else {
_max_cur = round(((max_pwr - _live_pwr) / evse.getVoltage() / 3) + (evse.getAmps()));
}



_changed = true;
Expand Down
3 changes: 3 additions & 0 deletions src/divert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ void DivertTask::update_state()
if (_mode == DivertMode::Eco)
{
double voltage = _evse->getVoltage();
if (config_threephase_enabled()) {
voltage = voltage * 3;
}

// Calculate current
if (mqtt_grid_ie != "")
Expand Down
14 changes: 9 additions & 5 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ void mqttmsg_callback(MongooseString topic, MongooseString payload) {
grid_ie = payload_str.toInt();
DBUGF("grid:%dW", grid_ie);
divert.update_state();
//recalculate shaper
if (shaper.getState()) {
shaper.shapeCurrent();

// if shaper use the same topic as grid_ie
if (mqtt_live_pwr == mqtt_grid_ie) {
shaper.setLivePwr(grid_ie);
}
}
else if (topic_string == mqtt_live_pwr)
Expand Down Expand Up @@ -311,8 +312,11 @@ mqtt_connect()
if(config_current_shaper_enabled())
{
if (mqtt_live_pwr != "") {
mqttclient.subscribe(mqtt_live_pwr);
yield();
if ( mqtt_live_pwr != mqtt_grid_ie ) {
// only subscribe once
mqttclient.subscribe(mqtt_live_pwr);
yield();
}
}
}
// subscribe to vehicle information from MQTT if we are configured for it
Expand Down