Skip to content

Commit bab6d5a

Browse files
committed
Allow shaper to use same topic as grid_ie
fix shaper with grid_ie
1 parent a285f54 commit bab6d5a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/current_shaper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ void CurrentShaperTask::shapeCurrent() {
122122
if (mqtt_solar != "") {
123123
max_pwr += solar;
124124
}
125-
else if (mqtt_grid_ie != "" && (grid_ie <= 0)) {
126-
max_pwr -= grid_ie;
127-
}
128125
}
129126
if(!config_threephase_enabled())
130127
_max_cur = round(((max_pwr - _live_pwr) / evse.getVoltage()) + (evse.getAmps()));

src/mqtt.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ void mqttmsg_callback(MongooseString topic, MongooseString payload) {
7676
grid_ie = payload_str.toInt();
7777
DBUGF("grid:%dW", grid_ie);
7878
divert.update_state();
79-
//recalculate shaper
80-
if (shaper.getState()) {
81-
shaper.shapeCurrent();
79+
80+
// if shaper use the same topic as grid_ie
81+
if (mqtt_live_pwr == mqtt_grid_ie) {
82+
shaper.setLivePwr(grid_ie);
8283
}
8384
}
8485
else if (topic_string == mqtt_live_pwr)
@@ -311,8 +312,11 @@ mqtt_connect()
311312
if(config_current_shaper_enabled())
312313
{
313314
if (mqtt_live_pwr != "") {
314-
mqttclient.subscribe(mqtt_live_pwr);
315-
yield();
315+
if ( mqtt_live_pwr != mqtt_grid_ie ) {
316+
// only subscribe once
317+
mqttclient.subscribe(mqtt_live_pwr);
318+
yield();
319+
}
316320
}
317321
}
318322
// subscribe to vehicle information from MQTT if we are configured for it

0 commit comments

Comments
 (0)