From 29cfc1c89f5de1f458210656a58695154e4f596f Mon Sep 17 00:00:00 2001 From: Kevin Petremann Date: Fri, 23 Jun 2023 20:23:00 +0200 Subject: [PATCH] fix: message was only sent each 5 minutes --- cmd/dht2mqtt/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dht2mqtt/main.go b/cmd/dht2mqtt/main.go index 88fb4e1..b39efa3 100644 --- a/cmd/dht2mqtt/main.go +++ b/cmd/dht2mqtt/main.go @@ -17,7 +17,7 @@ func watchAndPublish(sensorName string, publisher mqtt.Publisher, ch <-chan sens var lastPayload sensor.Payload lastChange := time.Now() for sensorPayload := range ch { - if sensorPayload.EqualTo(lastPayload) || time.Since(lastChange) > 5*time.Minute { + if !sensorPayload.EqualTo(lastPayload) || time.Since(lastChange) > 5*time.Minute { lastPayload = sensorPayload err := publisher.Publish(sensorName, sensorPayload) if err != nil {