k4cg / matomat-service

Matomat as a Service (MaaS)
MIT License
5 stars 2 forks source link

Set MQTT Message Header as "RETAIN" #29

Closed noqqe closed 5 years ago

noqqe commented 5 years ago

Hi,

In our setup we need MQTT messages to be sent with the "Retain" Flag .

If a broker receives a topic for which there are no current subscribers, it will discard the topic unless the publisher indicates that the topic is to be retained. This allows new subscribers to a topic to receive the most current value rather than waiting for the next update from a publisher.

from wikipedia

Could you please set this header in the event dispatcher for mqtt?

https://github.com/eclipse/paho.mqtt.golang/blob/88c4622b8e24c52f64a0caaa28e40b91629bb6e6/packets/packets.go#L244-L250

Bonus Points: Make it configurable :P

noqqe commented 5 years ago

Adiditional info:

1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/octopi/temperature/tool0', ... (57 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/octopi/temperature/bed', ... (57 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/octopi/progress/printing', ... (84 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/octopi/mqtt', ... (12 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/door/default/bme280/pressure', ... (87 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/door/default/bme280/temperature', ... (86 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/door/default/bme280/humidity', ... (86 bytes))
1549961865: Sending PUBLISH to spacestatuscrawler (d0, q0, r1, m0, 'sensors/door/default/status', ... (87 bytes))

whereas matomat

1549961873: Sending CONNACK to matomat (0, 0)
1549961873: Received PUBLISH from matomat (d0, q0, r0, m0, 'sensors/matomat/', ... (41 bytes))
1549961873: Received DISCONNECT from matomat
winterMate commented 5 years ago

Fixed with PR/33