Replies: 3 comments
-
I think its because you've used the retain message flag. The broker always retains the last message that was sent from some client and will dish it out when a new client connects regardless of whether its been sent to the client on a previous connect. I find retained messages can be a bit of a pain as a new connection will alway receive a retained message even if its an old and out of date message. I got caught when I was lured into thinking an old retained message of a temperature reading was a current reading when I freshly connected to my broker and thought the temperature sensor must have thrown a wobbly :-) |
Beta Was this translation helpful? Give feedback.
-
Can you point out to me where I set the retain flag? I looked through the mqtt_as source and it looks like everywhere retain occurs the default is |
Beta Was this translation helpful? Give feedback.
-
Well this is embarrassing... I see that the retain is set on the publisher, not the subscriber. Looked a bit about mqtt an retain and see you can clear a retained message by sending a zero by message with retain being false. Did the trick. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First, a huge thank you to Peter for a great library. I am connecting an ESP32 with a 433mhz receiver and transmitter to publish via MQTT so I can use home assistant for "smart" use of RF controlled ceiling fans. I started down the path of using the callback setup as I understand it fairly well, but tried out the event setup and it all worked. I have one quirk though that shows I don't understand enough what is going on.
When I lose connectivity, or when I restart the device, the "callback" I have running triggered by the message fires, even if no message has been received from a given topic. Why is that?
My use case is pretty much exactly the readme example, just trigger a different function.
Code for clarity:
I'm not sure how it is that the messages function is being called when there is no message that was received. I literally start this up and yet it still fires. I'm admittedly very unclear on the whole event queue concept and I suspect it stems from that.
Also, I thought it was pretty awesome that with two libraries from Peter I was able to get this up in running in just a morning of work. Really great stuff. Thank you.
Thanks in advance for any guidance anyone is able to provide.
Best,
Nick
Beta Was this translation helpful? Give feedback.
All reactions