mqtt2_device retain flag configuration

Begonnen von jacko, 16 Januar 2023, 18:30:34

Vorheriges Thema - Nächstes Thema


I can't get the retain flag configuration correct and I am confused!

The mqtt2_device Ref says:
if the topic name ends with :r, then the retain flag is set

If I have no space between the end of the topic and the :r, ie .../POWER:r, then the subscribers don't see the message. But if I leave a space, ie .../POWER :r, then the message payload includes the :r which subscribers can't decode correctly (without extra coding).

I thought that the retain flag should be independent of the topic and payload, and was expecting it to be set by an attribute.

What am I missing?


ZitatWhat am I missing?
No idea, but you dont tell us enough details to get one.

I tried to reproduce it, but I see no issues:

- started mosquitto (no special parameters)

- in FHEM:
define m2c MQTT2_CLIENT localhost:1883
define m2d MQTT2_DEVICE
attr m2d setList do hello:r people
set m2d do

- in the shell, after a while:
% mosquitto_sub -v -t #
hello people


I have had another look at this in the cool light of day. What I am doing is fundamentally the same as the example provided. But today my code works!!
What did I do differently? I issued a "shutdown restart" command. I guess restarting resets the broker connection somehow. 

For the record, I am additionally using the publish command where -r can be used to set the retain flag, for example
define n_Door_closed_mqtt notify DoorClosedSensor:.* set Broker publish -r stat/Garage/Door/Closed/POWER $EVTPART0

Much happier now it is all working.