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

Switch to retained publication for MQTT target #2

Merged
merged 1 commit into from
Aug 6, 2022

Conversation

andypiper
Copy link
Contributor

Propose changing the MQTT publication to retained by default, this makes it easier to see the last reading published from an Enviro sensor if the viewer / consumer / subscriber joins later. There is already a timestamp in the publication message so should be no risk of being confused at whether that reflects the current, or past, status of the Enviro. Added comments to indicate how to switch this back to False if preferred.

As an aside, I'm now comparing the format of these messages to those published by the MQTT sample shipped with the classic Enviro+ HAT, and will probably send a PR for the latter to get the data formats more aligned if possible.

Signed-off-by: Andy Piper andypiper@users.noreply.github.com

Signed-off-by: Andy Piper <andypiper@users.noreply.github.com>
@lowfatcode lowfatcode merged commit fda5650 into pimoroni:main Aug 6, 2022
andypiper added a commit to andypiper/enviroplus-python that referenced this pull request Aug 18, 2022
Per [the change I suggested to the Pico-based Enviro code](pimoroni/enviro#2), with this change, the MQTT messages will be published with the retain flag set, so that if a consumer is not subscribed, the most recent set of readings can still be read by a future subscriber later. 

This supports the [homebridge-enviroplus plugin](mhawkshaw/homebridge-enviroplus#2 (comment)) better, so that a publication is more likely to exist on the topic even if the Pi with Enviroplus / this example code is not running at the time. 

Additional update to consider would be to align the message data formats between this sample and the newer Enviro product line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants