2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

HMCCU: Sync client device data after get devicelist

git-svn-id: https://svn.fhem.de/fhem/trunk@10101 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
fhemzap 2015-12-05 18:59:41 +00:00
parent ad219b3684
commit e4b1b9d979

View File

@ -950,6 +950,7 @@ foreach(devid, root.Devices().EnumUsedIDs())
foreach my $hmdef (split /\n/,$response) {
my @hmdata = split /;/,$hmdef;
if ($hmdata[0] eq 'D') {
# 1=Interface 2=Device-Address 3=Device-Name 4=Device-Type 5=Channel-Count
$HMCCU_Devices{$hmdata[2]}{name} = $hmdata[3];
$HMCCU_Devices{$hmdata[2]}{type} = $hmdata[4];
$HMCCU_Devices{$hmdata[2]}{interface} = $hmdata[1];
@ -960,6 +961,7 @@ foreach(devid, root.Devices().EnumUsedIDs())
$count++;
}
elsif ($hmdata[0] eq 'C') {
# 1=Channel-Address 2=Channel-Name
$HMCCU_Devices{$hmdata[1]}{name} = $hmdata[2];
$HMCCU_Devices{$hmdata[1]}{addtype} = 'chn';
$HMCCU_Addresses{$hmdata[2]}{address} = $hmdata[1];
@ -968,6 +970,22 @@ foreach(devid, root.Devices().EnumUsedIDs())
}
}
# Update client devices
foreach my $d (keys %defs) {
# Get hash of client device
my $ch = $defs{$d};
next if (!defined ($ch->{IODev}) || !defined ($ch->{ccuaddr}));
my $add = $ch->{ccuaddr};
# Update device or channel attributes if it has changed in CCU
$ch->{ccuname} = $HMCCU_Devices{$add}{name}
if (!defined ($ch->{ccuname}) || $ch->{ccuname} ne $HMCCU_Devices{$add}{name});
$ch->{ccuif} = $HMCCU_Devices{$add}{interface}
if (!defined ($ch->{ccuif}) || $ch->{ccuif} ne $HMCCU_Devices{$add}{interface});
$ch->{ccutype} = $HMCCU_Devices{$add}{type}
if (!defined ($ch->{ccutype}) || $ch->{ccutype} ne $HMCCU_Devices{$add}{type});
}
return $count;
}