-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Fix Xiaomi merged packet parsing #1293
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
Conversation
@Alex9779 I improved the while loop slightly and the new code works for me, but I do not have a sensor which broadcasts multiple values at once like the CGG1, hence I cannot fully test the reporting of multiple values. You can download my changes from here: https://github.com/ahpohl/esphome/tree/multi_values. I do not fully understand how the multi values are actually being reported. |
I saw you branch this morning looked over it bit didn't have time to really think through and answer. |
I reviewed your code, I could rename the variables, but I am still not sure about the checks, not mine and not yours actually, when entering the loop and just before... So what do you expect now? Shall I take some changes and commit them to my PR? Shall I withdraw and you create a new one? |
Most sensors will cleanly process the payload and will not enter the loop again when all data is processed (
I have PR #1291 still pending. If you agree, I could easily extend it to include issue esphome/issues#1500. |
7e1a5b0
to
aea9c3a
Compare
I checked the multi value reporting with the dummy payload This answers my last question and I am fine to go ahead with either of our code versions. |
Yeah and that is what is happening. When initially discovered it was just the battery level which is appended, there are no other reports yet but we decided to make it robust so it will be future proof if there might be other devices doing this with several different types of values. I updated my code with your changes to values and length checking, test were successful and I still get the battery level from the devices which use that. I just have one doubt regarding the initial check in the loop, this will be only reached if you have that residual data with encrypted payloads and not for normal devices. So on a normal parse I will never see that "value parsing is complete". Maybe a different message might make more sense? |
Oh btw:
I don't think we should mix those two topics... :D |
esphome/components/xiaomi_ble/xiaomi_ble.cpp
Outdated
10000
span>
Show resolved
Hide resolved
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.
Looks good. I think that's it.
* Fix Xiaomi merged packet parsing solves #1500 * renamed variables and updated payload and value checking * renamed function and parameter * add function to header * changed log message
* Fix Xiaomi merged packet parsing solves esphome#1500 * renamed variables and updated payload and value checking * renamed function and parameter * add function to header * changed log message
Description:
fixes parsing of Xiaomi merged packets
Related issue (if applicable): fixes esphome/issues#1500
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: