From 0162f7d80b2ef489f73a2406312f748aa9a60d19 Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Wed, 26 Jul 2017 21:47:18 +0000 Subject: [PATCH] collectord: fixing RSSI readings (Forum: #54482) git-svn-id: https://svn.fhem.de/fhem/trunk@14798 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/PRESENCE/collectord | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fhem/contrib/PRESENCE/collectord b/fhem/contrib/PRESENCE/collectord index 6a324ef00..9c11d1fcf 100755 --- a/fhem/contrib/PRESENCE/collectord +++ b/fhem/contrib/PRESENCE/collectord @@ -863,6 +863,7 @@ sub aggregateRooms my $previous = "absence"; my %rssi_results = (); + my $hroom; my @rooms; my $key; @@ -922,7 +923,7 @@ sub aggregateRooms $highest_key = $key; } - $rssi_results{$key} = $h->{$rssi_addon_data_key}; + $rssi_results{$key} = $h->{$rssi_addon_data_key}; } else { @@ -939,20 +940,22 @@ sub aggregateRooms if($rssi_available and defined($highest_key)) { Log 2, "successful RSSI comparisation (highest $rssi_addon_data_key value $highest_value found in room $highest_key" if(@rooms > 1); - @rooms = ($highest_key); + $hroom = $highest_key; } } if(@rooms > 0) { - my $rssi_data = join(";", map { "rssi_".$_."='".$rssi_results{$_}."'" } map { s/\s+/_/g } grep {$rssi_results{$_}} keys %rssi_results); - return "present;room='".join(",",sort @rooms). - (defined($hash->{$rooms[0]}{data}) ? "';".$hash->{$rooms[0]}{data} : ""). + my $rssi_data = join(";", map("rssi_".$_."='".$rssi_results{$_}."'", map {s/\s+/_/rg } keys %rssi_results))); + my $ret = "present". + (defined($hroom) ? ";room='".$hroom."'" : ""). + "rooms='".join(",",sort @rooms)."'". + (defined($hroom) ? ";".$hash->{$hroom}{data} : (defined($hash->{$rooms[0]}{data}) ? "';".$hash->{$rooms[0]}{data} : "")). (defined($rssi_data) ? ";".$rssi_data : ""); } else { - return "absence"; + return "absence;room=;rooms=;rssi=;"; } }