Skip to content

Commit 7dc0578

Browse files
committed
fix mqtt /override topic publishing too much props
fix override topic not publishing props if there's no state prop removed useless if condition
1 parent 45762ea commit 7dc0578

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/evse_man.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "event_log.h"
1111
#include "divert.h"
1212
#include "current_shaper.h"
13+
#include "manual.h"
1314

1415
static EvseProperties nullProperties;
1516

@@ -267,7 +268,6 @@ bool EvseManager::evaluateClaims(EvseProperties &properties)
267268
DynamicJsonDocument event(capacity);
268269
event["manual_override"] = 1;
269270
event_send(event);
270-
// update /override topic to mqtt
271271
event.clear();
272272
mqtt_publish_json(event, "/override");
273273
}
@@ -439,6 +439,12 @@ unsigned long EvseManager::loop(MicroTasks::WakeReason reason)
439439
{
440440
_evaluateTargetState = false;
441441
setTargetState(_targetProperties);
442+
443+
if ( manual.isActive() ) {
444+
// update /override topic to mqtt
445+
mqtt_publish_override();
446+
}
447+
442448
}
443449
return MicroTask.Infinate;
444450
}

src/mqtt.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,22 +404,18 @@ mqtt_publish_claim() {
404404

405405
void
406406
mqtt_publish_override() {
407+
DBUGLN("MQTT publish_override()");
407408
if(!config_mqtt_enabled() || !mqttclient.connected()) {
408409
return;
409410
}
410411
const size_t capacity = JSON_OBJECT_SIZE(40) + 1024;
411412
DynamicJsonDocument override_data(capacity);
412413
EvseProperties props;
413414
//check if there an override claim
414-
if (evse.clientHasClaim(EvseClient_OpenEVSE_Manual)) {
415+
if (evse.clientHasClaim(EvseClient_OpenEVSE_Manual) || manual.isActive()) {
415416
props = evse.getClaimProperties(EvseClient_OpenEVSE_Manual);
416417
//check if there's state property in override
417-
if(props.getState() != 0) {
418-
props.serialize(override_data);
419-
}
420-
else {
421-
override_data["state"] = "null";
422-
}
418+
props.serialize(override_data);
423419
}
424420
else override_data["state"] = "null";
425421
mqtt_publish_json(override_data, "/override");

0 commit comments

Comments
 (0)