fix(mqtt): publishSession nicht bei GRATIS-only Burst (lastBurstSec == 0)

This commit is contained in:
MaPaLo76 2026-02-23 19:25:43 +01:00
parent d0d4666cf7
commit ff67b07144
3 changed files with 17 additions and 16 deletions

View File

@ -35,12 +35,12 @@ void loop() {
wifiConnector.loop();
mqttClient.loop();
// MQTT: Session-Publish nach jedem abgeschlossenen Burst
// MQTT: Session-Publish nur wenn Netto-Zeit vorhanden (kein GRATIS-only Burst)
if (laserTracker.consumeBurstEnd()) {
mqttClient.publishSession(
laserTracker.getLastBurstSeconds(),
settings.get().gratisSeconds
);
int lastBurst = laserTracker.getLastBurstSeconds();
if (lastBurst > 0) {
mqttClient.publishSession(lastBurst, settings.get().gratisSeconds);
}
}
// Display mit aktuellen Werten aktualisieren

View File

@ -83,12 +83,13 @@ void loop() {
// MQTT: Session-Publish nach Burst-Ende
if (laserTracker.consumeBurstEnd()) {
LOG_I("TEST-MQTT", "BurstEnd erkannt -> publishSession (lastBurst=%ds)",
laserTracker.getLastBurstSeconds());
mqttClient.publishSession(
laserTracker.getLastBurstSeconds(),
settings.get().gratisSeconds
);
int lastBurst = laserTracker.getLastBurstSeconds();
if (lastBurst > 0) {
LOG_I("TEST-MQTT", "BurstEnd erkannt -> publishSession (lastBurst=%ds)", lastBurst);
mqttClient.publishSession(lastBurst, settings.get().gratisSeconds);
} else {
LOG_I("TEST-MQTT", "BurstEnd erkannt, aber nur Gratiszeit -> kein Publish");
}
}
// Display

View File

@ -75,12 +75,12 @@ void loop() {
wifiConnector.loop();
mqttClient.loop();
// MQTT: Session-Publish nach Burst-Ende
// MQTT: Session-Publish nur wenn Netto-Zeit vorhanden (kein GRATIS-only Burst)
if (laserTracker.consumeBurstEnd()) {
mqttClient.publishSession(
laserTracker.getLastBurstSeconds(),
settings.get().gratisSeconds
);
int lastBurst = laserTracker.getLastBurstSeconds();
if (lastBurst > 0) {
mqttClient.publishSession(lastBurst, settings.get().gratisSeconds);
}
}
// Display