Feature: Dump hex data from meter to MQTT (#1071)

* Send raw data debug to MQTT

* Publish hexdump to /data

* Sensor for /data, but it doesnt work
This commit is contained in:
Gunnar Skjold
2025-12-01 14:02:07 +01:00
committed by GitHub
parent 9252a810df
commit 8438020dbd
15 changed files with 96 additions and 33 deletions

View File

@@ -1041,6 +1041,9 @@ void handleMeterConfig() {
debugE_P(PSTR("Unknown meter source selected: %d"), meterConfig.source);
}
ws.setMeterConfig(meterConfig.distributionSystem, meterConfig.mainFuse, meterConfig.productionCapacity);
if(mc != NULL && Debug.isActive(RemoteDebug::DEBUG)) {
mc->setMqttHandlerForDebugging(mqttHandler);
}
config.ackMeterChanged();
}
}
@@ -1557,6 +1560,9 @@ void postConnect() {
if(!debug.telnet) {
Debug.stop();
}
if(mc != NULL && Debug.isActive(RemoteDebug::DEBUG)) {
mc->setMqttHandlerForDebugging(mqttHandler);
}
} else {
Debug.stop();
}
@@ -1632,6 +1638,7 @@ void MQTT_connect() {
if(mqttHandler->getFormat() != mqttConfig.payloadFormat) {
delete mqttHandler;
mqttHandler = NULL;
mc->setMqttHandlerForDebugging(NULL);
} else if(config.isMqttChanged()) {
mqttHandler->setConfig(mqttConfig);
switch(mqttConfig.payloadFormat) {
@@ -1680,10 +1687,14 @@ void MQTT_connect() {
break;
case 255:
mqttHandler = new PassthroughMqttHandler(mqttConfig, &Debug, (char*) commonBuffer, &updater);
mc->setMqttHandlerForDebugging(mqttHandler);
break;
}
}
ws.setMqttHandler(mqttHandler);
if(mc != NULL && Debug.isActive(RemoteDebug::DEBUG)) {
mc->setMqttHandlerForDebugging(mqttHandler);
}
if(mqttHandler != NULL) {
mqttHandler->connect();