Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Retain Flag #799

Closed
lloydbayley opened this issue Jan 4, 2023 · 8 comments · Fixed by #1185
Closed

MQTT Retain Flag #799

lloydbayley opened this issue Jan 4, 2023 · 8 comments · Fixed by #1185

Comments

@lloydbayley
Copy link

💡 The Idea
Would it be possible to add a retain flag to the MQTT notification?

It would be handy to see what the last notification was before a reboot or close of subscription for any reason.
I suppose QOS could be done at the same time if you're in the code, but the retain flag would be a nice addition.

@skellycode
Copy link

I'd also love to see the retain flag added. It's a critical feature for many use-cases!

@caronc
Copy link
Owner

caronc commented Aug 23, 2024

For this request, do you wnat to just cache the last notification sent to disk and nothing more?

@skellycode
Copy link

the retain flag is part of the MQTT protocol. The MQTT server itself manages the retention of messages, so no caching would be required for apprise. We just need the option to send the retain flag as a part of the MQTT message.

"In MQTT, when a publisher sends a message to a topic, the broker broadcasts it to all the clients subscribed to that topic. But if no clients are subscribed to the topic when a message is sent, the broker discards the message. Consequently, new or reconnecting clients will never receive the message — this is where retained messages come in.

The retained messages feature allows MQTT brokers to persist the last known message on a topic. You can enable this feature by sending a PUBLISH packet to the broker with the retain flag set to true (retain=1). When the broker sees this flag, it knows to persist the message in the topic it’s been published to. That way, new or reconnecting subscribers get that last message when they join the topic."

@caronc
Copy link
Owner

caronc commented Aug 23, 2024

I feel so stupid, I'm so, so sorry. I thought this request was to actually have Apprise persist the last message. I didn't realize it's just a flag passed along 😬.

I'll have a look at the mqtt docs for the library Apprise depends on. It should be straight forward i hope

@lloydbayley
Copy link
Author

Take your time. This was almost two years ago and I can't remember why I needed it now, so I must have worked around it.

@caronc caronc linked a pull request Aug 23, 2024 that will close this issue
4 tasks
@caronc
Copy link
Owner

caronc commented Aug 23, 2024

Issue resolved in very simple PR. The amount of time you all waited ws a big issue between my keyboard and chair... 🤦‍♂️ 👀 .

What's important is the next release of Apprise will have this even if now (this many years later) it's of no use to you

@lloydbayley
Copy link
Author

We all have those moments. completely understand. It's just a good thing you didn't put it on the internet and tell people!! :) I'm actually starting to have an idea why I wanted it, so all is not lost!

@lloydbayley
Copy link
Author

lloydbayley commented Aug 25, 2024

Update: Just tested this in a controlled env and IT VERKS!!!! (Best said with a German accent).
I'm starting to remember more what I was going to use it for and will explore that next week! Thanks!
Now I just have to work out how to make everything upgrade to the commits since last release or does that require another point release on your end? (I'm not completely across how to make up the commits since releases yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants