2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-15 16:19:11 +00:00

98_UbiquitiMP.pm: fix groupPorts changes at runtime

git-svn-id: https://svn.fhem.de/fhem/trunk@8516 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
wzut 2015-05-02 17:14:24 +00:00
parent 1985e2cd5e
commit bfa8675e23

View File

@ -28,6 +28,7 @@
# first svn Version
# 23.04.15 add Set Extensions for 1 Port Ubi , change Client to UbiquitiOut,
# 25.06.15 add german docu, fix some timing problems
# 02.05.15 fix groupPorts change at runtime
package main;
@ -120,10 +121,11 @@ sub UbiquitiMP_Define($$) {
if( !defined( $attr{$a[0]}{subDevices} ) ) { $attr{$a[0]}{subDevices} = "1"}
$hash->{".subdevices"} = $attr{$a[0]}{subDevices};
$hash->{Clients} = ":UbiquitiOut:";
$hash->{PORTS} = 0;
$hash->{force} = 0;
$hash->{ERRORCOUNT} = 0;
$hash->{Clients} = ":UbiquitiOut:";
$hash->{PORTS} = 0;
$hash->{force} = 0;
$hash->{ERRORCOUNT} = 0;
$hash->{".grouplist"} = "";
readingsSingleUpdate($hash, "state", "defined",0);
@ -226,6 +228,14 @@ sub UbiquitiMP_Attr(@)
UbiquitiMP_createSets($hash);
}
}
elsif ($cmd eq "del")
{
if ($attrName eq "groupPorts")
{
$attr{$name}{groupPorts} = "";
UbiquitiMP_createSets($hash);
}
}
return undef;
}
@ -870,19 +880,29 @@ sub UbiquitiMP_createSets($)
for (my $j=1; $j<= $hash->{PORTS}; $j++) { $sets{"Out".$j} = $setcmds; $hash->{group_ALL} .= "$j,"; }
$sets{"ALL"} = $setcmds;
chop($hash->{group_ALL}); # das letzte Komma weg
if ($hash->{".grouplist"})
{
@a = split("," , $hash->{".grouplist"});
foreach (@a) { delete $hash->{"group_".$_}; }
$hash->{".grouplist"} = "";
}
if ($list)
{
@a = split(" " , $list);
foreach (@a)
{
@a = split(" " , $list);
foreach (@a)
{
@b = split("=" , $_);
if ($b[0] && $b[1])
if ($b[0] && (index($b[1],",") > 0))
{
$hash->{"group_".$b[0]} = $b[1];
$sets{$b[0]} = $setcmds;
$hash->{".grouplist"} .= $b[0].",";
}
}
chop($hash->{".grouplist"});
}
return;
}