-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
CGPR1 motion sensor inconsistent battery report #559
Comments
@hugalafutro Are you able to make some hci dumps. I want to check what the sensor is sending. |
I'm at work at the moment, but if you leave me steps how to obtain the dumps I'll get on it when I get back home (around 22:30). |
You can run the following command.
If you use HA Os, this won’t work., let me know if that is the case. The above command will create a text file. Let it run for 15 minutes. You can upload it here. |
I made a ~15mins long hci dump for both hci0 and hci1 (as I have both checked in the integration options), where hci1 is the pi bt and hci0 is bt usb dongle, although sometimes after reboot or when one of the adapters "dies" and restarts it can be other way around.
hci0: dump.txt edit: forgot to mention I run ha in docker with "host" network mode so I believe that shouldn't be an issue as ha os would be. |
Could you also send me the encryption key. This sensor sends encrypted advertisements. |
Here's the encryption key: |
Could you do me a favor, and change line 797-799 in from payload_start = next_start
return result to payload_start = next_start
if device_type == "CGPR1":
if "battery" in result:
_LOGGER.error("Battery reading for CGPR1 Adv: %s", data.hex())
return result This will collect some better filtered data for debugging in your HA log (as error). Keep it running for a few hours and post the error messages here. You can remove the lines after you have the logs. |
I changed the line in
I do not know python so I hope it's still gonna work. If it does I will post the output later. |
I updated the code in my previous post, I should have used CGPR1 of course, not ATC. Also fixed the warning you get. Could you change the code and try again? |
I did the changes and it's now outputting lines like
I will post later when there is more of them. |
Yes, that’s what we need. Keep it running for a couple of hours. |
Got this so far, let me know if you need more
|
I analyzed the data. It is indeed sending these strange readings. As you can see, the 100% readings are send once every 11 minutes approx. The other "wrong" messages that increase by 1 and are send once an hour (at 18 minutes past the hour). But the strange thing is that in both payloads, the
What I can do is applying a filter on the battery readings to ignore readings that deviate more than x%, but that would still record wrong readings that are close to 100% (e.g. if I set x = 10%, than all wrong advertisements between 90% and 99% are still taken into account. |
I'm curious what MiHome is showing. could you check around 18 minutes after the hour, what Mi Home is showing? If it is also using this data, it would be showing the "wrong" value for about 3-4 minutes. |
The xiaomi home app doesn't show the battery info just a full battery icon like so: https://turbomrak.o5.ddns.net/s/5ftJ9L32rnzfriM Clicking on anything just shows empty data. This is honestly 2nd time ever I opened the app since I got the token. Perhaps it's because I use older version with the vevs modification to get the encryption token? |
I have no idea, it looks like a firmware issue. Can you check if there is a firmware update? |
Says I have latest version 1.1.1_0228 when I try firmware update. I tried updating the app, but same result. I think your idea about just filtering the wrong readings out could work. |
In Qingping mode, everything is fine. I have not tested the change in battery readings. So far, only 100%. |
I have (finally) created a fix. Please try by installing 7.9.2-beta. Sorry for the long wait. Let me know if it fixes the issue. |
I have installed the beta, will report if the graph stopped misbehaving later. Thanks for your work! |
Released as final in 7.9.2 |
Discussed in #557
Originally posted by hugalafutro November 13, 2021
Hi,
I've noticed that my CGPR1 motion sensor reports battery as such:
which sometimes triggered my automation to warn me battery in iot device is going low. I selected "use median" for the particular sensor in the integration options, but the graph still looks wonky.
Just wondering if others with this sensor see the same by any chance and could this be indicative of the actual battery being close to dying?
edit: larger history shows this repeats cyclically:
The text was updated successfully, but these errors were encountered: