Skip to content
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

Issue with Temperature value less than 10degC #2

Closed
randomdisco opened this issue Jul 18, 2018 · 4 comments
Closed

Issue with Temperature value less than 10degC #2

randomdisco opened this issue Jul 18, 2018 · 4 comments

Comments

@randomdisco
Copy link

randomdisco commented Jul 18, 2018

Hi,
It appears as if the sensor platform code stops returning values if the temperature is below 10degC. This possibly also affects humidity but I can't verify this.

I'm running Hass.io on a RPI 3 with several of these sensors. The ones above 10degC continue to work normally; only one is dropping below 10deg C and when it does temperature, humidity, and battery values for only this sensor freeze and don't update until temp goes back above 10degC.

Suspect there is a single digit temperature (and humidity) bug in the code? I've never debugged python code before but I'm happy to try and look tonight.

I've had a quick look at the code and this might be the issue:

    # Parse the output
    res = re.search("( [0-9a-fA-F][0-9a-fA-F])+", result)

which is in
def write_readnotif_ble(mac, handle, value, retries=3, timeout=20, adapter=‘hci0’):
and
def read_ble(mac, handle, retries=3, timeout=20, adapter=‘hci0’):

Appears as if it needs to have 2 characters for a result to be found… But if the display is returning a 0 in front this should work. Wondering if the parse of the handle from the sensor (in format 0xXX) is only returning 1 (e.g. 8.3) rather than 2 (e.g. 08.3) characters for the non-decimal part…

Some comments are here with 2 other users with the same issue:
https://community.home-assistant.io/t/xiaomi-mijia-bluetooth-temperature-humidity-sensor-compatibility/43568/36

Great work on the sensor code - it was a breeze to get the sensors configured and running. Happy to help with this bug if I can!

Cheers,
Stewart

@randomdisco
Copy link
Author

I was actually looking at the wrong code, so apologies. I still think there is a bug with the line I mentioned though. If you're still developing this I think this might be better:

data=bytearray.fromhex(result).decode()
temp,humid  = data.replace("T=", "").replace("H=", "").rstrip(' \t\r\n\0').split(" ")

@flavio20002
Copy link
Owner

You are right. I will fix it. Thanks.

Flavio

@taulen
Copy link

taulen commented Aug 26, 2018

This issue is still there right ? Not working for me.

@flavio20002
Copy link
Owner

Fixed with 189f5e0

Repository owner deleted a comment from taulen Dec 16, 2018
Repository owner deleted a comment from pacman789 Dec 16, 2018
Repository owner deleted a comment from taulen Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants