-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update to using Paho MQTT v2 API calls #3
Comments
For reference, full changes here: https://github.com/eclipse/paho.mqtt.python/releases/tag/v2.0.0 Realized that there might be an issue with conflicting logger definitions? |
I'll take a look at this today and try and integrate V2. May need testing for backwards compatibility (maybe not though since it's a docker image). |
The Example: import paho.mqtt.client as mqtt
class MyClientClass(mqtt.Client):
_logger = 10 # this is an attribute of a sub-class of mqtt.Client
hw = "Hello World!"
@property
def logger(self)
"""This is a property to control accessing the attr, since this is a subclass, a conflict will arise rather than overriding if things arent handled properly"""
# You can do some additonal logic before returning a result
self.logger += 5
return self._logger
@logger.setter
def logger(self, value):
if not isinstance(value, int):
raise TypeError(f"The supplied value is the wrong type: {type(value)}, must be int.")
self._logger = value
if __name__ == "__main__":
x = MyClientClass()
print(f"{x.logger = } // {x.hw = }")
from the release notes: Possible breaking change: Add properties to access most Client attribute. Closes eclipse-paho/paho.mqtt.python#764. |
Should be good to go. New image is pushed, everything seems to be working ok on my end. |
Thanks! Builds fine on my end too and it's up and running, but haven't tested events yet. If anything comes up, I'll file a separate issue. Thanks so much for the work on this! |
Request to update code to use the new Paho MQTT v2 API calls.
I have taken my uneducated attempt at changing the code here: https://github.com/esand/dahuavto2mqtt.
The reason codes changed from a straight int to a ReasonCode type which can be an int, or a list/dict of ints for multiple codes. Supposedly you can use .getName() to get the text description for the code(s), so I modified the code to remove the call to the const list of defined error codes. My understanding of Python is zero though, so I'm not sure if I did it right or not 😄
My hope is that the work I did in my fork helps you in updating your repo correctly.
The text was updated successfully, but these errors were encountered: