Closed amagr0 closed 2 years ago
I think I have an idea where the issue is.
If you look into the code of sensirion.py, you can see that there are two types of humidity conversion. Only V1 is implemented.
def _decodeHumidityV1(byte_data):
# GadgetBle::_convertHumidityV1 - return static_cast<uint16_t>(((value / 100) * 65535) + 0.5f);
return round((int.from_bytes(byte_data, byteorder='little') / 65535) * 100, 2)
def _decodeHumidityV2(byte_data):
# GadgetBle::_convertHumidityV2 - return static_cast<uint16_t>((((value + 6.0) * 65535) / 125.0) + 0.5f);
return
So, lets assume the sensor is using V2 in stead of V1. The sensor will than send the following value
((71.18 + 6.0) * 65535) / 125 = 40464 (9E10
in bytes)
So, BLE monitor receives 40464, but assumes it is V1.
40464 / 65535 * 100 = 61.74%
So, what needs to be done is that we use V2 decoding for humidity. I don't know if if there is a Version flag in the data, will have a look.
ah, it looks like SHT4xx always uses V2, so we should use V2 in stead of V1. I will fix this.
Brilliant! Thanks @Ernst79
Should be fixed in 10.6.1
Should be fixed in 10.6.1
Fixed!
What happened?
I have the SHT40 Smart Gadget already in HA through Bluetooth Low Energy Monitor Integration but the Humidity data that I'm getting in HA is relatively low compared to the Gadget values, aprox. 10% of Humidity lower.
Ex.: -------------------------- Temp | Humidity SHT4X Smart Gadget -- 22.09C | 71.18% HA BLE ----------------- 22.09C | 61.71%
SHT40 Gadget Firmware: 3.2 (up to date)
Passive BLE Monitor integration 10.6.0
Home Assistant 2022.11.2 Supervisor 2022.10.2 Operating System 9.3
Sensor type
Sensirion SHT40 Smart Gadget
Relevant log output