From 5dae00fd85f24c62cd1f76701ea147ccc59d4b0f Mon Sep 17 00:00:00 2001 From: zrhutto Date: Mon, 10 Jan 2022 19:33:38 -0500 Subject: [PATCH] Parse temperature and humidity from GVH5101 Small patch to correctly parse temperature and humidity information from GVH5101 devices that has reports values at different offsets than GVH5075/GVH5074. Reusing the existing file given the similarities of the two devices. Device type detection based on signature in advertising packet. --- blerry/blerry_model_GVH5075.be | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/blerry/blerry_model_GVH5075.be b/blerry/blerry_model_GVH5075.be index 5e8d705..6495f0d 100644 --- a/blerry/blerry_model_GVH5075.be +++ b/blerry/blerry_model_GVH5075.be @@ -36,15 +36,20 @@ def handle_GVH5075(value, trigger, msg) output_map['Time_via_' + device_topic] = output_map['Time'] output_map['RSSI_via_' + device_topic] = output_map['RSSI'] end - var basenum = (bytes('00') + adv_data[3..5]).get(0,-4) - if basenum >= 0x800000 - output_map['Temperature'] = (0x800000 - basenum)/10000.0 - output_map['Humidity'] = ((basenum - 0x800000) % 1000)/10.0 - else - output_map['Temperature'] = basenum/10000.0 - output_map['Humidity'] = (basenum % 1000)/10.0 + var dev_type = adv_data.get(0,-2) + var basenum = 0x00000000 + if dev_type == 0x88EC # GVH5075 + basenum = (bytes('00') + adv_data[3..5]).get(0,-4) + if basenum >= 0x800000 + basenum -= 0x800000 + end + output_map['Battery'] = adv_data.get(6,1) + elif dev_type == 0x0100 # GVH5101 + basenum = (bytes('00') + adv_data[4..6]).get(0,-4) + output_map['Battery'] = adv_data.get(7,1) end - output_map['Battery'] = adv_data.get(6,1) + output_map['Temperature'] = basenum/10000.0 + output_map['Humidity'] = (basenum % 1000)/10.0 output_map['DewPoint'] = round(get_dewpoint(output_map['Temperature'], output_map['Humidity']), this_device['temp_precision']) output_map['Temperature'] = round(output_map['Temperature'], this_device['temp_precision']) output_map['Humidity'] = round(output_map['Humidity'], this_device['humi_precision']) @@ -63,4 +68,4 @@ end # map function into handles array device_handles['GVH5075'] = handle_GVH5075 -require_active['GVH5075'] = false \ No newline at end of file +require_active['GVH5075'] = false