From 13e5daee5845a2d095412bdfdbdf93e2488e0bde Mon Sep 17 00:00:00 2001 From: T0RST3N Date: Thu, 23 Mar 2017 18:43:32 +0100 Subject: [PATCH] FIX missing humidity reading FIX missing readings on sensors --- FHEM/71_XiaomiSmartHome_Device.pm | 14 +++++++------- controls_mish.txt | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FHEM/71_XiaomiSmartHome_Device.pm b/FHEM/71_XiaomiSmartHome_Device.pm index 83c77d9..6274e6b 100644 --- a/FHEM/71_XiaomiSmartHome_Device.pm +++ b/FHEM/71_XiaomiSmartHome_Device.pm @@ -25,7 +25,7 @@ package main; use strict; use warnings; -my $version = "0.05"; +my $version = "0.06"; sub XiaomiSmartHome_Device_updateSReading($); ##################################### @@ -82,28 +82,28 @@ sub XiaomiSmartHome_Device_Read($$$){ readingsSingleUpdate($hash, "no_motion", "0", 1 ); } } - elsif(defined $data->{no_motion}){ + if(defined $data->{no_motion}){ Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " NO_motion: " . $data->{no_motion}; readingsSingleUpdate($hash, "no_motion", "$data->{no_motion}", 1 ); } - elsif(defined $data->{voltage}){ + if(defined $data->{voltage}){ Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Voltage: " . $data->{voltage}; readingsSingleUpdate($hash, "voltage", "$data->{voltage}", 1 ); } - elsif(defined $data->{temperature}){ + if(defined $data->{temperature}){ my $temp = $data->{temperature}; $temp =~ s/(^[-+]?\d+?(?=(?>(?:\d{2})+)(?!\d))|\G\d{2}(?=\d))/$1./g; Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Temperature: " . $temp; readingsSingleUpdate($hash, "temperature", "$temp", 1 ); } - elsif(defined $data->{humidity}){ + if(defined $data->{humidity}){ my $hum = $data->{humidity}; $hum =~ s/(^[-+]?\d+?(?=(?>(?:\d{2})+)(?!\d))|\G\d{2}(?=\d))/$1./g; Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Humidity: " . $hum; readingsSingleUpdate($hash, "humidity", "$hum", 1 ); } - elsif ($decoded->{'cmd'} eq 'heartbeat'){ - readingsSingleUpdate($hash, $decoded->{'sid'}, 'heartbeat', 1 ); + if ($decoded->{'cmd'} eq 'heartbeat'){ + readingsSingleUpdate($hash, 'heartbeat', $decoded->{'sid'} , 1 ); } XiaomiSmartHome_Device_update($hash); return $hash->{NAME}; diff --git a/controls_mish.txt b/controls_mish.txt index affe469..06d2106 100644 --- a/controls_mish.txt +++ b/controls_mish.txt @@ -1,2 +1,2 @@ UPD 2017-03-22_18:48:03 14910 FHEM/71_XiaomiSmartHome.pm -UPD 2017-03-22_18:18:22 7905 FHEM/71_XiaomiSmartHome_Device.pm \ No newline at end of file +UPD 2017-03-23_18:32:10 7891 FHEM/71_XiaomiSmartHome_Device.pm \ No newline at end of file