MYSENSORS_DEVICE: fix readingMapping for multiple sensors of same type

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@6923 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2014-11-09 11:43:23 +00:00
parent dfc9b53b1c
commit a3204ea5db

View File

@ -311,7 +311,7 @@ sub Attr($$$$) {
FIND: foreach my $id (keys %$readingMappings) { FIND: foreach my $id (keys %$readingMappings) {
my $readingsForId = $readingMappings->{$id}; my $readingsForId = $readingMappings->{$id};
foreach my $type (keys %$readingsForId) { foreach my $type (keys %$readingsForId) {
if ($readingsForId->{$type}->{name} // "" eq $1) { if (($readingsForId->{$type}->{name} // "") eq $1) {
delete $readingsForId->{$type}; delete $readingsForId->{$type};
unless (keys %$readingsForId) { unless (keys %$readingsForId) {
delete $readingMappings->{$id}; delete $readingMappings->{$id};
@ -325,11 +325,9 @@ sub Attr($$$$) {
my $typeMappings = $hash->{typeMappings}; my $typeMappings = $hash->{typeMappings};
if (my @match = grep {$typeMappings->{$_}->{type} eq $typeStr} keys %$typeMappings) { if (my @match = grep {$typeMappings->{$_}->{type} eq $typeStr} keys %$typeMappings) {
my $type = shift @match; my $type = shift @match;
$hash->{readingMappings}->{$id}->{$type} = { $readingMappings->{$id}->{$type}->{name} = $1;
name => $1,
};
if (@values) { if (@values) {
$hash->{readingMappings}->{$id}->{$type}->{val} = {map {$_ =~ /^(.+):(.+)$/; $1 => $2} @values}; #TODO range? $readingMappings->{$id}->{$type}->{val} = {map {$_ =~ /^(.+):(.+)$/; $1 => $2} @values}; #TODO range?
} }
} else { } else {
return "unknown reading type $typeStr"; return "unknown reading type $typeStr";