From 04f92b69b0bee181037053095e87f44e4483307a Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Wed, 31 May 2017 17:11:22 +0000 Subject: [PATCH] collectord: Fix rssi addon data (thx to Micky, Forum: #54482) git-svn-id: https://svn.fhem.de/fhem/trunk@14439 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/PRESENCE/collectord | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fhem/contrib/PRESENCE/collectord b/fhem/contrib/PRESENCE/collectord index f393393bc..6a324ef00 100755 --- a/fhem/contrib/PRESENCE/collectord +++ b/fhem/contrib/PRESENCE/collectord @@ -862,7 +862,7 @@ sub aggregateRooms my ($hash) = @_; my $previous = "absence"; - + my %rssi_results = (); my @rooms; my $key; @@ -914,13 +914,15 @@ sub aggregateRooms elsif(@{$a} == 0 and keys(%{$h}) > 0) # new addon data style { # check rssi - if($rssi_available and exists($h->{$rssi_addon_data_key}) and $h->{$rssi_addon_data_key} =~ /^-?(?:\d+\.)\d+$/) + if(exists($h->{$rssi_addon_data_key}) and $h->{$rssi_addon_data_key} =~ /^-?(?:\d+\.)?\d+$/) { if(!defined($highest_value) or (defined($highest_value) and $h->{$rssi_addon_data_key} > $highest_value)) { - $highest_value = $h->{rssi}; + $highest_value = $h->{$rssi_addon_data_key}; $highest_key = $key; } + + $rssi_results{$key} = $h->{$rssi_addon_data_key}; } else { @@ -943,7 +945,10 @@ sub aggregateRooms if(@rooms > 0) { - return "present;rooms='".join(",",sort @rooms).(defined($hash->{$rooms[0]}{data}) ? "';".$hash->{$rooms[0]}{data} : ""); + 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} : ""). + (defined($rssi_data) ? ";".$rssi_data : ""); } else {