i wrapped paho mqtt a few years ago, but not implementing whole interface. i wote a bunch of apps on top of my wrapper, one being my own weewx mqtt service/driver, other apps are various mqtt producers and consumers
thanks for the heads-up on the mqtt interface change. it prompted me to polish my wrapper a bit, with things i learnt over last few years. one is to put json encoding/decoding at the heart of the wrapper - i expose python objects rather than mqtt messages, and the python objects are converted to json (strings) in the wrapper to/from the mqtt wire i’ve yet to find a use for clean_session=false. cheers ⊣GE⊢ > On 15 Mar 2024, at 10:57 am, bell...@gmail.com <bellri...@gmail.com> wrote: > > Just a quick update. > I’m happy with this approach, but eventually V1 API support will be removed. > Ideally this will be long after V1 clients are gone. But, I’ve been burnt > once…. So, I’m implementing the approach below. > I’m going to use the factory pattern. I already had a class ‘wrapping’ paho > mqtt. I will now have a base class that implements all of the logic. I will > have subclasses as necessary for the different versions of paho mqtt. These > subclasses will interact with paho mqtt and pass data to the base class to do > the real work. I’ll have a factory to provide the appropriate class to > interact with paho mqtt. > Hopefully this will insulate a bit from breaking changes, or at least make it > easier to react to them. > rich > > On Sunday 11 February 2024 at 16:49:25 UTC-5 bell...@gmail.com wrote: >> I've pretty much settled on this approach. Minimally tested >> >> try: >> callback_api_version = mqtt.CallbackAPIVersion.VERSION1 >> self.client = >> mqtt.Client(callback_api_version=callback_api_version, >> client_id=mqtt_options['clientid'], >> userdata=self.userdata, >> >> clean_session=mqtt_options['clean_session']) >> except AttributeError: >> self.client = mqtt.Client(client_id=mqtt_options['clientid'], >> userdata=self.userdata, >> >> clean_session=mqtt_options['clean_session']) >> >> rich >> On Sunday 11 February 2024 at 15:21:58 UTC-5 matthew wall wrote: >>> On Sunday, February 11, 2024 at 1:37:20 PM UTC-5 bell...@gmail.com <> wrote: >>> It currently will not work with paho mqtt 2.0.0 or higher. >>> >>> rich, i too am interested in what you learn, as i will probably have to >>> update weewx-mqtt as well. m > > > -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to weewx-user+unsubscr...@googlegroups.com > <mailto:weewx-user+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/8b3fba7b-dfae-4105-8138-7381e5697017n%40googlegroups.com > > <https://groups.google.com/d/msgid/weewx-user/8b3fba7b-dfae-4105-8138-7381e5697017n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/96563991-9D76-4812-B101-FF1FB2A29BA6%40geddy.au.