mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 20:17:45 +00:00
HUE: move device to new bridge if uniqueid stays the same
git-svn-id: https://svn.fhem.de/fhem/trunk@20979 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3c5feb0ef0
commit
d1ebfbbb81
@ -1908,7 +1908,30 @@ HUEBridge_dispatch($$$;$)
|
||||
$changed .= $chash->{ID};
|
||||
}
|
||||
} else {
|
||||
Log3 $name, 2, "$name: message for unknown device received: $code";
|
||||
my $found;
|
||||
if( my $serial = $lights->{$id}{uniqueid} ) {
|
||||
foreach my $chash ( values %{$modules{HUEDevice}{defptr}} ) {
|
||||
next if( !$chash->{uniqueid} );
|
||||
next if( $chash->{helper}{devtype} );
|
||||
next if( $serial ne $chash->{uniqueid} );
|
||||
|
||||
my $cname = $chash->{NAME};
|
||||
my $old = AttrVal( $cname, 'IODev', '<unknown>' );
|
||||
|
||||
Log3 $name, 2, "moving $cname [$serial] from $old to $name";
|
||||
|
||||
HUEDevice_IODevChanged($chash, undef, $name, $id);
|
||||
|
||||
HUEDevice_Parse($chash, $lights->{$id});
|
||||
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$found ) {
|
||||
Log3 $name, 3, "$name: message for unknown device received: $code";
|
||||
}
|
||||
}
|
||||
}
|
||||
HUEBridge_updateGroups($hash, $changed) if( $changed );
|
||||
|
@ -280,6 +280,10 @@ HUEDevice_IODevChanged($$$;$)
|
||||
Log3 $name, 1, "$name: can't change IODev for TYPE $hash->{TYPE}";
|
||||
return undef;
|
||||
}
|
||||
if( $new_id && $hash->{helper}->{devtype} ) {
|
||||
Log3 $name, 1, "$name: can't change IODev for groups and sensors";
|
||||
return undef;
|
||||
}
|
||||
|
||||
$old = AttrVal($name, "IODev", undef) if( !$old );
|
||||
|
||||
@ -311,6 +315,9 @@ HUEDevice_IODevChanged($$$;$)
|
||||
} elsif( $new ) {
|
||||
$hash->{DEF} .= " IODev=$new"
|
||||
}
|
||||
|
||||
$hash->{DEF} =~ s/[^\s]+/$new_id/ if( $new_id );
|
||||
|
||||
$hash->{DEF} =~ s/ / /g;
|
||||
|
||||
return $new;
|
||||
|
Loading…
x
Reference in New Issue
Block a user