mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 20:24:36 +00:00
74_XiaomiBTLESens: code clean
git-svn-id: https://svn.fhem.de/fhem/trunk@15922 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fe7859b511
commit
349de7a22a
@ -1,5 +1,6 @@
|
||||
# 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_XiaomiBTLESens: Code clean
|
||||
- feature: 21_HEOSPlayer: add input URL as set command
|
||||
- feature: 74_Unifi: add new set command to en-/disable Site Status-LEDs
|
||||
- bugfix: 74_XiaomiBTLESens: fix ssh gatttool which test
|
||||
|
@ -47,7 +47,7 @@ use JSON;
|
||||
use Blocking;
|
||||
|
||||
|
||||
my $version = "2.0.1";
|
||||
my $version = "2.0.3";
|
||||
|
||||
|
||||
|
||||
@ -664,19 +664,14 @@ sub XiaomiBTLESens_FlowerSensHandle0x35($$) {
|
||||
my $temp;
|
||||
|
||||
if( $dataSensor[1] eq "ff" ) {
|
||||
$temp = hex("0x".$dataSensor[1].$dataSensor[0]) - hex("0xffff");
|
||||
$readings{'temperature'} = hex("0x".$dataSensor[1].$dataSensor[0]) - hex("0xffff") / 10;
|
||||
} else {
|
||||
$temp = hex("0x".$dataSensor[1].$dataSensor[0]);
|
||||
$readings{'temperature'} = hex("0x".$dataSensor[1].$dataSensor[0]) / 10;
|
||||
}
|
||||
|
||||
my $lux = hex("0x".$dataSensor[4].$dataSensor[3]);
|
||||
my $moisture = hex("0x".$dataSensor[7]);
|
||||
my $fertility = hex("0x".$dataSensor[9].$dataSensor[8]);
|
||||
|
||||
$readings{'temperature'} = $temp/10;
|
||||
$readings{'lux'} = $lux;
|
||||
$readings{'moisture'} = $moisture;
|
||||
$readings{'fertility'} = $fertility;
|
||||
|
||||
$readings{'lux'} = hex("0x".$dataSensor[4].$dataSensor[3]);
|
||||
$readings{'moisture'} = hex("0x".$dataSensor[7]);
|
||||
$readings{'fertility'} = hex("0x".$dataSensor[9].$dataSensor[8]);
|
||||
|
||||
$hash->{helper}{CallBattery} = 0;
|
||||
return \%readings;
|
||||
@ -691,11 +686,9 @@ sub XiaomiBTLESens_ThermoHygroSensHandle0x18($$) {
|
||||
|
||||
|
||||
Log3 $name, 5, "XiaomiBTLESens ($name) - Thermo/Hygro Sens Handle0x18";
|
||||
|
||||
my $blevel = hex("0x".$notification);
|
||||
|
||||
$readings{'batteryLevel'} = $blevel;
|
||||
$readings{'battery'} = ($blevel > 20?"ok":"low");
|
||||
$readings{'batteryLevel'} = hex("0x".$notification);
|
||||
$readings{'battery'} = (hex("0x".$notification) > 20?"ok":"low");
|
||||
|
||||
$hash->{helper}{CallBattery} = 1;
|
||||
XiaomiBTLESens_CallBattery_Timestamp($hash);
|
||||
@ -713,12 +706,9 @@ sub XiaomiBTLESens_ThermoHygroSensHandle0x10($$) {
|
||||
Log3 $name, 5, "XiaomiBTLESens ($name) - Thermo/Hygro Sens Handle0x10";
|
||||
|
||||
$notification =~ s/\s+//g;
|
||||
# 54 3d 31 37 2e 33 20 48 3d 35 32 2e 35 00
|
||||
my $temp = pack('H*',substr($notification,4,8)); # 31 37 2e 33
|
||||
my $hum = pack('H*',substr($notification,18,8)); # 35 32 2e 35
|
||||
|
||||
$readings{'temperature'} = $temp;
|
||||
$readings{'humidity'} = $hum;
|
||||
$readings{'temperature'} = pack('H*',substr($notification,4,8));
|
||||
$readings{'humidity'} = pack('H*',substr($notification,18,8));
|
||||
|
||||
$hash->{helper}{CallBattery} = 0;
|
||||
return \%readings;
|
||||
@ -736,9 +726,7 @@ sub XiaomiBTLESens_ThermoHygroSensHandle0x24($$) {
|
||||
|
||||
$notification =~ s/\s+//g;
|
||||
|
||||
my $fw = pack('H*',$notification);
|
||||
|
||||
$readings{'firmware'} = $fw;
|
||||
$readings{'firmware'} = pack('H*',$notification);
|
||||
|
||||
$hash->{helper}{CallBattery} = 0;
|
||||
return \%readings;
|
||||
@ -756,9 +744,7 @@ sub XiaomiBTLESens_ThermoHygroSensHandle0x3($$) {
|
||||
|
||||
$notification =~ s/\s+//g;
|
||||
|
||||
my $devname = pack('H*',$notification);
|
||||
|
||||
$readings{'devicename'} = $devname;
|
||||
$readings{'devicename'} = pack('H*',$notification);
|
||||
|
||||
$hash->{helper}{CallBattery} = 0;
|
||||
return \%readings;
|
||||
|
Loading…
x
Reference in New Issue
Block a user