volkszaehler / mbmd

ModBus Measurement Daemon - simple reading of data from ModBus meters and grid inverters
BSD 3-Clause "New" or "Revised" License
224 stars 81 forks source link

Publish to mqtt with the retain flag? #313

Open bikeymouse opened 1 year ago

bikeymouse commented 1 year ago

Hi,

Thanks for your great software. I'm using this to publish the measurements to mqtt which works fine. I only would like to have the messages published with the retain flag set.

In that way the consumers of the data would get the latest state immediately after connecting to my mqtt broker.

Is there a way to configure this?

bikeymouse commented 1 year ago

Ah, I found it: I changed line 136 in mqtt.go from go m.Publish(topic, false, message) to go m.Publish(topic, true, message)

Now the messages are retained ;-)