-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
The sensor stops updating after some time and requires a restart of the server #12
Comments
Personally, I sometimes have a problem with the BT-interface, not related to the operation of the component and HA (very rarely. Moreover, it usually occurs when nobody is in the house 🤷♂️, syslog then begins to fill up with BT-errors). My workaround is described here. I think it's worth checking if juggling the BT interface helps, rather than restarting the container. But I can’t say exactly how to do it correctly in the case of the container, I have no experience with Docker. Perhaps we faced a problem in this area... |
Thanks for the answer. I have installed the Beta and the latest reading gives me a rssi of -74. To answer your first question, yes, I am using the bluetooth also for other components, more specifically for miflora (that uses the same code base as the official mitemp_bt component) and Switchbot. But what is interesting is that when my mitemp_bt sensor based on the custom component starts not updating the other bluetooth components continue to work. I looked at your post. Docker on RPI is slightly different and I can restart the bluetooth through the command I also followed this comment when I was trying to fix the official component and made my bluetooth auto restart every couple of hours. I might try to deactivate this behaviour to see if it fixes the problem. Would activating debug mode for the custom component provide me more info on why it is failing after some time? |
I don’t think so... Most likely, we will see the normal operation of the component. But you can try. I think the problem is that hcidump for some reason stops receiving BT LE advertisements, and starting hcitool after the problem occurs leads to nothing. That is, the component receives an "empty" dump, where there is nothing to process... At this moment, the component does not receive any information about the result of the execution of hcitool and hcidump it calls (except for the dump itself). I’ll think about how to do it right. |
@camfrout please try latest 0.4.0-beta.2 (just released) - there are some changes that may affect. And turn on debugging for the component - let's see at what stage the data are missing (does the component really get nothing, or are entities not updated for some reason). |
Sure. I just installed 0.4.0-beta.2 and kept the debug logs activated. |
Hi.
|
Hmm... Very interesting ... P.S. please verify if you enabled debugging like this, for example: logger:
default: warn
logs:
custom_components.mitemp_bt: debug |
Thanks! |
It seems to fail more than before now. Just a few minutes after restarting HA it has stopped updating. Here is what I have in the log:
Could it be that the code tries to parse the answer from another sensor rather than the temperature one and then gets an error because the data format is different? |
Yes, 0.4.0 beta supports all (known) BLE broadcasting Xiaomi sensors. |
Here are the logs after running for about 1 min: https://www.dropbox.com/s/6ub9ueabv1vs9d5/dump.txt?dl=0 |
Received, thank you. Today later I’ll take a look and will let you know. |
@camfrout @Ernst79 |
instead of bugged(#12) SpooledTemporaryFile
Done. Please try v0.4.0-beta.3 |
Thanks, updated. Will let you know if it keeps working. |
@Magalex2x14 Unfortunately, same error again with newest beta 3.
Seems that it is having an empty value, where it expects an integer. |
It expects hexadecimal number (base 16). I will dig further. |
I will prepare a code that will catch this exception and save the contents of the dump to a file so you can send it to me ... |
OK. Can you, please, replace try:
xvalue_length = int(data[xdata_point+4:xdata_point+6], 16)
except ValueError as error:
_LOGGER.critical("ValueError exception: %s", error)
_LOGGER.critical("DATA: '%s'", data)
_LOGGER.critical("HEX? xvalue_length: '%s'", data[xdata_point+4:xdata_point+6])
_LOGGER.critical("xvalue_typecode: '%s'", xvalue_typecode)
_LOGGER.critical("xdata_length: '%s'", xdata_length)
_LOGGER.critical("xdata_point: '%s'", xdata_point)
_LOGGER.critical("result: '%s'", result)
break Wait for the error occurs. Then you can reinstall component using HACS to revert changes. |
Running it now, will keep you posted. Are you reverting the last change, or do you keep the TemporaryFile ? |
After reading, I’m not sure now whether to return) The last posts in the topic about a bug for about a week... In addition, I’m not sure now that SpooledTemporaryFile really works with memory in our case:
The fileno() method seems to be called in subprocess.popen (which runs our hcidump). |
This comment has been minimized.
This comment has been minimized.
What does your esphome config has to do with this component? Which component is not working? Esphome or mitemp_bt? |
I have also installed the latest beta and changed the code as you asked. It has now been running for a few hours and is still getting updated without any problem but I could find this in the log anyway:
|
Mine has also given the error twice last night, but continues to work.
|
Thanks, guys. This is just what I need. |
@Magalex2x14 One thing I notice is that with the last change (try..., except...), the code at least continues to operate, due to the break. I reverted back to the beta3, and now it fails and stops right after the error occurs. So, even if you can't figure out what happens, we can always include some error handling and continue I guess. |
Yes I understand. Also considered this option. But I decided to first look at the "broken" packets. And they are strange, they do not fit in a well-known format. Today I’ll decide what to do with it. |
It's running for 24 hours now, without any errors or stopping sensor. Seems to be solved for me. |
Hi! I was running on the beta 3 with the change of code recommended here: #12 (comment) and it worked for several days without any issue. I now moved to the beta 4 and got the following error after about 2 hours. The component then stops updating and I need to restart HA.
|
@camfrout here is beta.5... Please, try it, and let me know if there are messages from custom_component.mitemp_bt in the log. I added the processing of your exception with the corresponding message - the component will not die. |
@camfrout version 0.4.0 (final) has been released. Can you confirm it is solved on your end and close the issue? |
Hey. I've been running version 0.4.0 for more than 12 hours without any issue so far so I will close this issue. |
Hi,
I have been using this custom component for the past week as the official one stopped reporting data after a couple of hours after each restart.
The custom component works really well for me but usually, after running HA for 2-3 days the sensor stops updating as well. I am running HA in a docker container on my Raspberry Pi 3.
If I connect to my docker container and run
hcitool lescan --duplicates
and ahcidump --raw
I can still see some data in my terminal.For now, my only temporary solution is to restart my docker container to get the sensor to update itself again. Is there anything else I could do, or any command I could run to make the sensor work again without restarting?
Ben
The text was updated successfully, but these errors were encountered: