Skip to content

Commit

Permalink
fix: message was only sent each 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
kpetremann committed Jun 23, 2023
1 parent fc6f382 commit 29cfc1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/dht2mqtt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 29cfc1c

Please sign in to comment.