From 025b1bf35c261e9b87e3c2cfa97cbb692ca7cd4e Mon Sep 17 00:00:00 2001 From: LeonGaultier Date: Wed, 13 Jun 2018 06:46:04 +0000 Subject: [PATCH] 74_XXiaomiBTLSens: Thermo/HydroSense new state format, new Readings batteryState and batteryPercent git-svn-id: https://svn.fhem.de/fhem/trunk@16857 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/74_XiaomiBTLESens.pm | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 0ae8a0205..2899e2267 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 74_XXiaomiBTLSens: Thermo/HydroSense new state format, new Reading + batteryState and batteryPercent - change: 49_SSCamSTRM: new attribute "forcePageRefresh" for better control of page refresh (for e.g. Floorplan,Dashboard) - feature: 89_FULLY: Added screen saver commands. diff --git a/fhem/FHEM/74_XiaomiBTLESens.pm b/fhem/FHEM/74_XiaomiBTLESens.pm index 850deeb47..49ae9e682 100644 --- a/fhem/FHEM/74_XiaomiBTLESens.pm +++ b/fhem/FHEM/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);