mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
HUE: move device to new bridge if uniqueid stays the same
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20979 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ffe3ea4e5f
commit
391a2ee950
@ -1908,7 +1908,30 @@ HUEBridge_dispatch($$$;$)
|
|||||||
$changed .= $chash->{ID};
|
$changed .= $chash->{ID};
|
||||||
}
|
}
|
||||||
} else {
|
} 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 );
|
HUEBridge_updateGroups($hash, $changed) if( $changed );
|
||||||
|
@ -280,6 +280,10 @@ HUEDevice_IODevChanged($$$;$)
|
|||||||
Log3 $name, 1, "$name: can't change IODev for TYPE $hash->{TYPE}";
|
Log3 $name, 1, "$name: can't change IODev for TYPE $hash->{TYPE}";
|
||||||
return undef;
|
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 );
|
$old = AttrVal($name, "IODev", undef) if( !$old );
|
||||||
|
|
||||||
@ -311,6 +315,9 @@ HUEDevice_IODevChanged($$$;$)
|
|||||||
} elsif( $new ) {
|
} elsif( $new ) {
|
||||||
$hash->{DEF} .= " IODev=$new"
|
$hash->{DEF} .= " IODev=$new"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hash->{DEF} =~ s/[^\s]+/$new_id/ if( $new_id );
|
||||||
|
|
||||||
$hash->{DEF} =~ s/ / /g;
|
$hash->{DEF} =~ s/ / /g;
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user