-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add DPT232 #5
base: master
Are you sure you want to change the base?
Add DPT232 #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Greig,
thanks for your contribution! Of course, I'm happy to add more KNX DPTs! Until now I've been lazy and only added the few DPTs needed for the KNX devices at my parents' home.
However, please take a look at my comments about the Python types returned/accepted by the decode/encode functions. I'd like to keep them as consistent and semantically fitting as possible.
test/test_conversion.py
Outdated
self.assertEqual(f'{0x801B10:X}', | ||
knxdclient.decode_value(bytes([0x80, 0x1B, 0x10]), knxdclient.KNXDPT.COLOUR_RGB)) | ||
self.assertEqual(f'{0x123456:X}', | ||
knxdclient.decode_value(bytes([0x12, 0x34, 0x56]), knxdclient.KNXDPT.COLOUR_RGB)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a "roundtrip" test here that checks that decode_value(encode_value(some_value, ...), ...) == some_value
.
This should also reveal the issue with the deviating datatypes, discussed in my other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ta. I shall tinker. (This first one might take us a little while, but it should speed any future ones. I appreciate the hand-holding).
Thanks Michael. I'll get onto these. (Sorry for the slow response - I didn't receive any notification from GitHub that you'd responded). |
Hi Michael,
This PR adds encoding and decoding of DPT 232.
I've never written unit tests before, but I think what I've done is valid:
Let me know if anything's not quite right and I'll amend as required.
If you're OK with it I'll add more DPTs as users of my captureKNX bring them to my attention??
Thanks.
- Greig.