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
Comments
My fix for this issue is to parse the response like text - strip the null character, split on space, split on equals. Negative temperatures should work too - the current forecast says I can test that by the weekend. This is my tested change to
|
Same here: 2018-09-24 10:40:59 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.mitemp_bt_temperature fails
Traceback (most recent call last):
File "/home/pi/.virtualenvs/ha/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
yield from self.async_device_update()
File "/home/pi/.virtualenvs/ha/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 353, in async_device_update
yield from self.hass.async_add_job(self.update)
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/pi/.virtualenvs/ha/lib/python3.5/site-packages/homeassistant/components/sensor/mitemp_bt.py", line 142, in update
data = self.poller.parameter_value(self.parameter)
File "/home/pi/.virtualenvs/ha/lib/python3.5/site-packages/mitemp_bt/mitemp_bt_poller.py", line 132, in parameter_value
return self._parse_data()[parameter]
File "/home/pi/.virtualenvs/ha/lib/python3.5/site-packages/mitemp_bt/mitemp_bt_poller.py", line 177, in _parse_data
res[MI_HUMIDITY] = float(data[9:13])
ValueError: could not convert string to float: '7.9\x00' @rmiddlet Thanks for your fix, and I have tested it by putting the sensor in the refrigerator. |
Seems like this is an issue with high negative numbers as well (<=-10.0C) but then it starts to parse at '=' since the humidity is shifted to the right. |
Can anyone get the fix into pip? I don't understand python pip repositories. |
From memory, on reviewing the raw output of the xiaomi temperature module, the fault is actually with the device for -0.1 -> -0.9. That is, the fault is in the raw data, not in the interpretation of the raw. |
Thank you Robert for quick answer. I assume that there is nothing that can be fixed from our side. Have a nice day! |
Hi,
Actually got the wrong code and debugged that but here I am and I think this is the one included with Home Assistant...
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.
I believe there is a single digit temperature (and humidity) bug in the code. I'd never debugged / written python code before tonight (so I'm hacking a bit) but I got this far.
A double figure temperature (15degC) returns a 14 byte code: 54 3d 32 30 2e 33 20 48 3d 34 36 2e 35 00
But a single digit temperature (8 degC) returns a 13 byte code: 54 3d 38 2e 32 20 48 3d 34 36 2e 36 00
I can't work out what type the data is in when it gets passed in here
But this then calls self._check_data() which calls self._parse_data()
And the bug I think lies here:
If temp is single digit this should be 2:5 and 8:12 and if humidity is single digits it should be 8:11.
I think the data is a byte array string... in which case this should work in _parse_data:
Great work on the sensor code - it was a breeze to get the sensors configured and running. Happy to help with this bug further if I can! I have no idea how to check this with Home Assistant or run unit tests and submit.
Cheers,
Stewart
The text was updated successfully, but these errors were encountered: