From f9f1ff53e164a30f2f19d4f1c1c3a495542551c8 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Tue, 12 Jun 2018 08:28:25 +0200 Subject: [PATCH] new state format for thermo/Hydro Sens --- 74_XiaomiBTLESens.pm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/74_XiaomiBTLESens.pm b/74_XiaomiBTLESens.pm index 477925d..fceec6a 100644 --- a/74_XiaomiBTLESens.pm +++ b/74_XiaomiBTLESens.pm @@ -50,7 +50,7 @@ eval "use Blocking;1" or $missingModul .= "Blocking "; #use Data::Dumper; only for Debugging -my $version = "2.0.13"; +my $version = "2.0.14"; @@ -656,8 +656,8 @@ sub XiaomiBTLESens_FlowerSensHandle0x38($$) { my @dataBatFw = split(" ",$notification); - $readings{'batteryLevel'} = hex("0x".$dataBatFw[0]); - $readings{'battery'} = (hex("0x".$dataBatFw[0]) > 15 ? "ok" : "low"); + #$readings{'batteryLevel'} = hex("0x".$dataBatFw[0]); + #$readings{'battery'} = (hex("0x".$dataBatFw[0]) > 15 ? "ok" : "low"); ### neue Vereinheitlichung für Batteriereadings Forum #800017 $readings{'batteryPercent'} = hex("0x".$dataBatFw[0]); $readings{'batteryState'} = (hex("0x".$dataBatFw[0]) > 15 ? "ok" : "low"); @@ -711,8 +711,11 @@ sub XiaomiBTLESens_ThermoHygroSensHandle0x18($$) { chomp($notification); - $readings{'batteryLevel'} = hex("0x".$notification); - $readings{'battery'} = (hex("0x".$notification) > 15 ? "ok" : "low"); + #$readings{'batteryLevel'} = hex("0x".$notification); + #$readings{'battery'} = (hex("0x".$notification) > 15 ? "ok" : "low"); + ### neue Vereinheitlichung für Batteriereadings Forum #800017 + $readings{'batteryPercent'} = hex("0x".$notification); + $readings{'batteryState'} = (hex("0x".$notification) > 15 ? "ok" : "low"); $hash->{helper}{CallBattery} = 1; XiaomiBTLESens_CallBattery_Timestamp($hash); @@ -797,7 +800,9 @@ sub XiaomiBTLESens_WriteReadings($$) { readingsBulkUpdate($hash,$r,$v); } - readingsBulkUpdateIfChanged($hash, "state", ($readings->{'lastGattError'}?'error':'active')); + readingsBulkUpdateIfChanged($hash, "state", ($readings->{'lastGattError'}?'error':'active')) if( AttrVal($name,'model','none') eq 'flowerSens' ); + readingsBulkUpdateIfChanged($hash, "state", ($readings->{'lastGattError'}?'error':'T: '.ReadingsVal($name,'temperature',0).' H: '.ReadingsVal($name,'humidity',0) ) if( AttrVal($name,'model','none') eq 'thermoHygroSens' ); + readingsEndUpdate($hash,1); @@ -959,8 +964,8 @@ sub CometBlueBTLE_CmdlinePreventGrepFalsePositive($) { Readings