mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
HMCCU: Update for 4.4 Beta
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@21191 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7ee098df2a
commit
0bed1502eb
@ -3659,7 +3659,6 @@ sub HMCCU_UpdateDeviceRoles ($$;$$)
|
|||||||
my ($ioHash, $clHash, $iface, $address) = @_;
|
my ($ioHash, $clHash, $iface, $address) = @_;
|
||||||
|
|
||||||
my $clType = $clHash->{TYPE};
|
my $clType = $clHash->{TYPE};
|
||||||
return if ($clType ne 'HMCCUCHN');
|
|
||||||
|
|
||||||
$iface = $clHash->{ccuif} if (!defined($iface));
|
$iface = $clHash->{ccuif} if (!defined($iface));
|
||||||
$address = $clHash->{ccuaddr} if (!defined($address));
|
$address = $clHash->{ccuaddr} if (!defined($address));
|
||||||
@ -6922,57 +6921,90 @@ sub HMCCU_GetSpecialDatapoints ($$$$$)
|
|||||||
my $type = $hash->{TYPE};
|
my $type = $hash->{TYPE};
|
||||||
my $ccutype = $hash->{ccutype};
|
my $ccutype = $hash->{ccutype};
|
||||||
|
|
||||||
|
# F: 1=Channel, 2=Device, 3=Both
|
||||||
|
# S: State Datapoint, C: Control datapoint
|
||||||
|
my %roleDPs = (
|
||||||
|
'SHUTTER_CONTACT' => { F => 3, S => 'STATE', C => '' },
|
||||||
|
'KEY' => { F => 3, S => 'PRESS_SHORT', C => 'PRESS_SHORT' },
|
||||||
|
'BLIND' => { F => 3, S => 'LEVEL', C => 'LEVEL' },
|
||||||
|
'SWITCH' => { F => 3, S => 'STATE', C => 'STATE' },
|
||||||
|
'DIMMER' => { F => 3, S => 'LEVEL', C => 'LEVEL' },
|
||||||
|
'WEATHER_TRANSMIT' => { F => 1, S => 'TEMPERATURE', C => 'TEMPERATURE' },
|
||||||
|
'THERMALCONTROL_TRANSMIT' => { F => 3, S => 'ACTUAL_TEMPERATURE', C => 'SET_TEMPERATURE' },
|
||||||
|
'CLIMATECONTROL_RT_TRANSCEIVER' => { F => 3, S => 'ACTUAL_TEMPERATURE', C => 'SET_TEMPERATURE' }
|
||||||
|
);
|
||||||
|
|
||||||
my $statedatapoint = AttrVal ($name, 'statedatapoint', '');
|
my $statedatapoint = AttrVal ($name, 'statedatapoint', '');
|
||||||
my $statechannel = AttrVal ($name, 'statechannel', '');
|
my $statechannel = AttrVal ($name, 'statechannel', '');
|
||||||
my $controldatapoint = AttrVal ($name, 'controldatapoint', $statedatapoint);
|
my $controldatapoint = AttrVal ($name, 'controldatapoint', $statedatapoint);
|
||||||
|
|
||||||
|
# If attribute statedatapoint is specified, use it
|
||||||
if ($statedatapoint ne '') {
|
if ($statedatapoint ne '') {
|
||||||
if ($statedatapoint =~ /^([0-9]+)\.(.+)$/) {
|
if ($statedatapoint =~ /^([0-9]+)\.(.+)$/) {
|
||||||
($sc, $sd) = ($1, $2);
|
($sc, $sd) = ($1, $2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sd = $statedatapoint;
|
$sd = $statedatapoint;
|
||||||
|
if ($statechannel eq '') {
|
||||||
|
# Try to find state channel
|
||||||
|
my $c = HMCCU_FindDatapoint ($hash, $type, -1, $sd, 3);
|
||||||
|
$sc = $c if ($c >= 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sc = $statechannel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sc = $statechannel if ($statechannel ne '' && $sc eq '');
|
|
||||||
|
|
||||||
|
# If attribute controldatapoint is specified, use it
|
||||||
if ($controldatapoint ne '') {
|
if ($controldatapoint ne '') {
|
||||||
if ($controldatapoint =~ /^([0-9]+)\.(.+)$/) {
|
if ($controldatapoint =~ /^([0-9]+)\.(.+)$/) {
|
||||||
($cc, $cd) = ($1, $2);
|
($cc, $cd) = ($1, $2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$cd = $controldatapoint;
|
$cd = $controldatapoint;
|
||||||
|
# Try to find control channel
|
||||||
|
my $c = HMCCU_FindDatapoint ($hash, $type, -1, $cd, 3);
|
||||||
|
$cc = $c if ($c >= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# For devices of type HMCCUCHN extract channel numbers from CCU device address
|
if (exists($hash->{ccurole})) {
|
||||||
if ($type eq 'HMCCUCHN') {
|
my $ccuRole = $hash->{ccurole};
|
||||||
$sc = $hash->{ccuaddr};
|
if ($type eq 'HMCCUCHN') {
|
||||||
$sc =~ s/^[\*]*[0-9A-Z]+://;
|
my ($da, $dc) = HMCCU_SplitChnAddr ($hash->{ccuaddr});
|
||||||
$cc = $sc;
|
$sc = $dc;
|
||||||
if ($sd eq '') {
|
$cc = $dc;
|
||||||
if (HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, 'STATE', 3)) { $sd = 'STATE'; }
|
if (exists($roleDPs{$ccuRole}) && $roleDPs{$ccuRole}{F} & 1) {
|
||||||
elsif (HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, 'LEVEL', 3)) { $sd = 'LEVEL'; }
|
$sd = $roleDPs{$ccuRole}{S} if ($roleDPs{$ccuRole}{S} ne '');
|
||||||
elsif (HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, 'PRESS_SHORT', 3)) { $sd = 'PRESS_SHORT'; }
|
$cd = $roleDPs{$ccuRole}{C} if ($roleDPs{$ccuRole}{C} ne '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
elsif ($type eq 'HMCCUDEV') {
|
||||||
else {
|
foreach my $roleDef (split(',', $ccuRole)) {
|
||||||
# Try to find state channel
|
my ($dc, $role) = split(':', $roleDef);
|
||||||
my $c = -1;
|
if (exists($roleDPs{$role}) && $roleDPs{$role}{F} & 2) {
|
||||||
if ($sc eq '' && $sd ne '') {
|
if ($roleDPs{$role}{S} ne '' && $sd eq '') {
|
||||||
$c = HMCCU_FindDatapoint ($hash, $type, -1, $sd, 3);
|
$sd = $roleDPs{$role}{S};
|
||||||
$sc = $c if ($c >= 0);
|
$sc = $dc;
|
||||||
}
|
}
|
||||||
# Try to find control channel
|
if ($roleDPs{$role}{C} ne '' && $cd eq '') {
|
||||||
if ($cc eq '' && $cd ne '') {
|
$cd = $roleDPs{$role}{C} ;
|
||||||
$c = HMCCU_FindDatapoint ($hash, $type, -1, $cd, 3);
|
$cc = $dc;
|
||||||
$cc = $c if ($c >= 0);
|
}
|
||||||
|
}
|
||||||
|
last if ($sd ne '' && $cd ne '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# By default set control channel and datapoint to state channel and datapoint
|
# By default set control channel and datapoint to state channel and datapoint
|
||||||
$cc = $sc if ($cc eq '');
|
$cc = $sc if ($cc eq '');
|
||||||
$cd = $sd if ($cd eq '');
|
$cd = $sd if ($cd eq '');
|
||||||
|
$hash->{hmccu}{state}{dpt} = $sd;
|
||||||
|
$hash->{hmccu}{state}{chn} = $sc;
|
||||||
|
$hash->{hmccu}{control}{dpt} = $cd;
|
||||||
|
$hash->{hmccu}{control}{chn} = $cc;
|
||||||
|
|
||||||
return ($sc, $sd, $cc, $cd);
|
return ($sc, $sd, $cc, $cd);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ sub HMCCUCHN_Set ($@)
|
|||||||
return undef if ($disable == 1);
|
return undef if ($disable == 1);
|
||||||
|
|
||||||
my $ioHash = $hash->{IODev};
|
my $ioHash = $hash->{IODev};
|
||||||
my $hmccu_name = $ioHash->{NAME};
|
my $ioName = $ioHash->{NAME};
|
||||||
if (HMCCU_IsRPCStateBlocking ($ioHash)) {
|
if (HMCCU_IsRPCStateBlocking ($ioHash)) {
|
||||||
return undef if ($opt eq '?');
|
return undef if ($opt eq '?');
|
||||||
return "HMCCUCHN: CCU busy";
|
return "HMCCUCHN: CCU busy";
|
||||||
@ -274,7 +274,7 @@ sub HMCCUCHN_Set ($@)
|
|||||||
|
|
||||||
# Log commands
|
# Log commands
|
||||||
HMCCU_Log ($hash, 3, "set $name $opt ".join (' ', @$a))
|
HMCCU_Log ($hash, 3, "set $name $opt ".join (' ', @$a))
|
||||||
if ($opt ne '?' && $ccuflags =~ /logCommand/ || HMCCU_IsFlag ($hmccu_name, 'logCommand'));
|
if ($opt ne '?' && $ccuflags =~ /logCommand/ || HMCCU_IsFlag ($ioName, 'logCommand'));
|
||||||
|
|
||||||
if ($opt eq 'datapoint') {
|
if ($opt eq 'datapoint') {
|
||||||
my $usage = "Usage: set $name datapoint {{datapoint} {value} | {datapoint}={value}} [...]";
|
my $usage = "Usage: set $name datapoint {{datapoint} {value} | {datapoint}={value}} [...]";
|
||||||
@ -329,7 +329,7 @@ sub HMCCUCHN_Set ($@)
|
|||||||
return HMCCU_SetError ($hash, min(0, $rc));
|
return HMCCU_SetError ($hash, min(0, $rc));
|
||||||
}
|
}
|
||||||
elsif (exists($stateCmds{$opt})) {
|
elsif (exists($stateCmds{$opt})) {
|
||||||
return HMCCU_SetError ($hash, -13) if ($sd eq '');
|
return HMCCU_SetError ($hash, -14) if ($cd eq '');
|
||||||
return HMCCU_SetError ($hash, -8)
|
return HMCCU_SetError ($hash, -8)
|
||||||
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
||||||
|
|
||||||
@ -340,7 +340,8 @@ sub HMCCUCHN_Set ($@)
|
|||||||
}
|
}
|
||||||
elsif ($opt eq 'toggle') {
|
elsif ($opt eq 'toggle') {
|
||||||
return HMCCU_SetError ($hash, -15) if ($stateVals eq '');
|
return HMCCU_SetError ($hash, -15) if ($stateVals eq '');
|
||||||
return HMCCU_SetError ($hash, -13) if ($cd eq '');
|
return HMCCU_SetError ($hash, -12) if ($cc eq '');
|
||||||
|
return HMCCU_SetError ($hash, -14) if ($cd eq '');
|
||||||
return HMCCU_SetError ($hash, -8)
|
return HMCCU_SetError ($hash, -8)
|
||||||
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
||||||
|
|
||||||
@ -427,7 +428,7 @@ sub HMCCUCHN_Set ($@)
|
|||||||
return HMCCU_SetError ($hash, -15) if ($stateVals eq '');
|
return HMCCU_SetError ($hash, -15) if ($stateVals eq '');
|
||||||
return HMCCU_SetError ($hash, "No state value for 'on' defined")
|
return HMCCU_SetError ($hash, "No state value for 'on' defined")
|
||||||
if (!exists($stateCmds{"on"}));
|
if (!exists($stateCmds{"on"}));
|
||||||
return HMCCU_SetError ($hash, -13) if ($cd eq '');
|
return HMCCU_SetError ($hash, -14) if ($cd eq '');
|
||||||
return HMCCU_SetError ($hash, -8)
|
return HMCCU_SetError ($hash, -8)
|
||||||
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
||||||
return HMCCU_SetError ($hash, "Can't find ON_TIME datapoint for device type")
|
return HMCCU_SetError ($hash, "Can't find ON_TIME datapoint for device type")
|
||||||
@ -504,15 +505,22 @@ sub HMCCUCHN_Set ($@)
|
|||||||
return HMCCU_SetError ($hash, "Receiver $receiver is not a HMCCUCHN or HMCCUDEV device");
|
return HMCCU_SetError ($hash, "Receiver $receiver is not a HMCCUCHN or HMCCUDEV device");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif (!HMCCU_IsChnAddr ($receiver, 0)) {
|
||||||
|
my ($rcvAdd, $rcvChn) = HMCCU_GetAddress ($ioHash, $receiver, '', '');
|
||||||
|
return HMCCU_SetError ($hash, "$receiver is not a valid CCU channel name")
|
||||||
|
if ($rcvAdd eq '' || $rcvChn eq '');
|
||||||
|
$receiver = "$rcvAdd:$rcvChn";
|
||||||
|
}
|
||||||
|
|
||||||
|
return HMCCU_SetError ($hash, "$receiver is not a link receiver of $name")
|
||||||
|
if (!HMCCU_IsValidReceiver ($ioHash, $ccuaddr, $ccuif, $receiver));
|
||||||
|
|
||||||
push @rcvList, $receiver;
|
push @rcvList, $receiver;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push @rcvList, HMCCU_GetReceivers ($ioHash, $ccuaddr, $ccuif);
|
push @rcvList, HMCCU_GetReceivers ($ioHash, $ccuaddr, $ccuif);
|
||||||
}
|
}
|
||||||
|
|
||||||
return HMCCU_SetError ($hash, "$receiver is not a link receiver of $name")
|
|
||||||
if (!HMCCU_IsValidReceiver ($ioHash, $ccuaddr, $ccuif, $receiver));
|
|
||||||
|
|
||||||
my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $ccuaddr, $ccuif);
|
my $devDesc = HMCCU_GetDeviceDesc ($ioHash, $ccuaddr, $ccuif);
|
||||||
return HMCCU_SetError ($hash, "Can't get device description")
|
return HMCCU_SetError ($hash, "Can't get device description")
|
||||||
if (!defined($devDesc));
|
if (!defined($devDesc));
|
||||||
@ -568,7 +576,7 @@ sub HMCCUCHN_Get ($@)
|
|||||||
return undef if ($disable == 1);
|
return undef if ($disable == 1);
|
||||||
|
|
||||||
my $ioHash = $hash->{IODev};
|
my $ioHash = $hash->{IODev};
|
||||||
my $hmccu_name = $ioHash->{NAME};
|
my $ioName = $ioHash->{NAME};
|
||||||
if (HMCCU_IsRPCStateBlocking ($ioHash)) {
|
if (HMCCU_IsRPCStateBlocking ($ioHash)) {
|
||||||
return undef if ($opt eq '?');
|
return undef if ($opt eq '?');
|
||||||
return "HMCCUCHN: CCU busy";
|
return "HMCCUCHN: CCU busy";
|
||||||
@ -577,7 +585,6 @@ sub HMCCUCHN_Get ($@)
|
|||||||
my $ccutype = $hash->{ccutype};
|
my $ccutype = $hash->{ccutype};
|
||||||
my $ccuaddr = $hash->{ccuaddr};
|
my $ccuaddr = $hash->{ccuaddr};
|
||||||
my $ccuif = $hash->{ccuif};
|
my $ccuif = $hash->{ccuif};
|
||||||
my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', 'STATE', '', '');
|
|
||||||
my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
|
my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
|
||||||
|
|
||||||
my $result = '';
|
my $result = '';
|
||||||
@ -585,7 +592,7 @@ sub HMCCUCHN_Get ($@)
|
|||||||
|
|
||||||
# Log commands
|
# Log commands
|
||||||
HMCCU_Log ($hash, 3, "get $name $opt ".join (' ', @$a))
|
HMCCU_Log ($hash, 3, "get $name $opt ".join (' ', @$a))
|
||||||
if ($opt ne '?' && $ccuflags =~ /logCommand/ || HMCCU_IsFlag ($hmccu_name, 'logCommand'));
|
if ($opt ne '?' && $ccuflags =~ /logCommand/ || HMCCU_IsFlag ($ioName, 'logCommand'));
|
||||||
|
|
||||||
if ($opt eq 'datapoint') {
|
if ($opt eq 'datapoint') {
|
||||||
my $objname = shift @$a;
|
my $objname = shift @$a;
|
||||||
@ -768,8 +775,9 @@ sub HMCCUCHN_Get ($@)
|
|||||||
</li><br/>
|
</li><br/>
|
||||||
<li><b>set <name> link <receiver> [<channel>] <parameter>=<value>[:<type>]</b><br/>
|
<li><b>set <name> link <receiver> [<channel>] <parameter>=<value>[:<type>]</b><br/>
|
||||||
Set multiple link parameters (parameter set LINK). Parameter <i>receiver</i> is the
|
Set multiple link parameters (parameter set LINK). Parameter <i>receiver</i> is the
|
||||||
name of a FHEM device of type HMCCUDEV or HMCCUCHN or a channel address. For FHEM
|
name of a FHEM device of type HMCCUDEV or HMCCUCHN or a channel address or a CCU
|
||||||
devices of type HMCCUDEV a <i>channel</i> number must be specified. Parameter <i>parameter</i> must be a valid
|
channel name. For FHEM devices of type HMCCUDEV a <i>channel</i> number must be specified.
|
||||||
|
Parameter <i>parameter</i> must be a valid
|
||||||
link configuration parameter name. If <i>type</i> is not specified, it's taken from
|
link configuration parameter name. If <i>type</i> is not specified, it's taken from
|
||||||
parameter set definition. The default <i>type</i> is STRING.
|
parameter set definition. The default <i>type</i> is STRING.
|
||||||
Valid types are STRING, BOOL, INTEGER, FLOAT, DOUBLE.
|
Valid types are STRING, BOOL, INTEGER, FLOAT, DOUBLE.
|
||||||
|
@ -389,7 +389,10 @@ sub HMCCUDEV_Set ($@)
|
|||||||
my $ccuif = $hash->{ccuif};
|
my $ccuif = $hash->{ccuif};
|
||||||
my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
|
my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
|
||||||
my $statevals = AttrVal ($name, 'statevals', '');
|
my $statevals = AttrVal ($name, 'statevals', '');
|
||||||
my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', 'STATE', '', '');
|
my ($sc, $sd, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', '', '', '');
|
||||||
|
my $stateVals = HMCCU_GetStateValues ($hash, $cd, 2);
|
||||||
|
my %stateCmds = split (/[:,]/, $stateVals);
|
||||||
|
my @states = keys %stateCmds;
|
||||||
|
|
||||||
my $result = '';
|
my $result = '';
|
||||||
my $rc;
|
my $rc;
|
||||||
@ -455,44 +458,33 @@ sub HMCCUDEV_Set ($@)
|
|||||||
);
|
);
|
||||||
return HMCCU_SetError ($hash, min(0, $rc));
|
return HMCCU_SetError ($hash, min(0, $rc));
|
||||||
}
|
}
|
||||||
elsif ($opt =~ /^($hash->{hmccu}{statevals})$/) {
|
elsif (exists($stateCmds{$opt})) {
|
||||||
my $cmd = $1;
|
return HMCCU_SetError ($hash, -12) if ($cc eq '');
|
||||||
my $objvalue = ($cmd ne 'devstate') ? $cmd : shift @$a;
|
return HMCCU_SetError ($hash, -14) if ($cd eq '');
|
||||||
|
return HMCCU_SetError ($hash, -8)
|
||||||
|
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $ccuaddr, $cd, 2));
|
||||||
|
|
||||||
return HMCCU_SetError ($hash, -11) if ($sc eq '');
|
|
||||||
return HMCCU_SetError ($hash, -13) if ($sd eq '');
|
|
||||||
return HMCCU_SetError ($hash, "Usage: set $name devstate {value}") if (!defined ($objvalue));
|
|
||||||
|
|
||||||
$objvalue =~ s/\\_/%20/g;
|
|
||||||
$rc = HMCCU_SetMultipleDatapoints ($hash,
|
$rc = HMCCU_SetMultipleDatapoints ($hash,
|
||||||
{ "001.$ccuif.$ccuaddr:$sc.$sd" => HMCCU_Substitute ($objvalue, $statevals, 1, undef, '') }
|
{ "001.$ccuif.$ccuaddr:$cc.$cd" => $stateCmds{$opt} }
|
||||||
);
|
);
|
||||||
return HMCCU_SetError ($hash, min(0, $rc));
|
return HMCCU_SetError ($hash, min(0, $rc));
|
||||||
}
|
}
|
||||||
elsif ($opt eq 'toggle') {
|
elsif ($opt eq 'toggle') {
|
||||||
return HMCCU_SetError ($hash, -15) if ($statevals eq '' || !exists($hash->{hmccu}{statevals}));
|
return HMCCU_SetError ($hash, -15) if ($stateVals eq '');
|
||||||
return HMCCU_SetError ($hash, -11) if ($sc eq '');
|
return HMCCU_SetError ($hash, -12) if ($cc eq '');
|
||||||
return HMCCU_SetError ($hash, -13) if ($sd eq '');
|
return HMCCU_SetError ($hash, -14) if ($cd eq '');
|
||||||
return HMCCU_SetError ($hash, -8) if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $sc, $sd, 2));
|
return HMCCU_SetError ($hash, -8)
|
||||||
|
if (!HMCCU_IsValidDatapoint ($hash, $ccutype, $cc, $cd, 2));
|
||||||
|
|
||||||
my $tstates = $hash->{hmccu}{statevals};
|
|
||||||
$tstates =~ s/devstate\|//;
|
|
||||||
my @states = split /\|/, $tstates;
|
|
||||||
my $stc = scalar (@states);
|
my $stc = scalar (@states);
|
||||||
|
my $curState = defined($hash->{hmccu}{dp}{"$cc.$cd"}{VALUES}{SVAL}) ?
|
||||||
|
$hash->{hmccu}{dp}{"$cc.$cd"}{VALUES}{SVAL} : $states[0];
|
||||||
|
|
||||||
my $objname = $ccuif.'.'.$ccuaddr.':'.$sc.'.'.$sd;
|
my $newState = '';
|
||||||
|
|
||||||
# Read current value of datapoint without updating reading
|
|
||||||
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname, 1);
|
|
||||||
Log3 $name, 2, "HMCCU: set toggle: GetDatapoint returned $rc, $result"
|
|
||||||
if ($ccuflags =~ /trace/);
|
|
||||||
return HMCCU_SetError ($hash, $rc, $result) if ($rc < 0);
|
|
||||||
|
|
||||||
my $objvalue = '';
|
|
||||||
my $st = 0;
|
my $st = 0;
|
||||||
while ($st < $stc) {
|
while ($st < $stc) {
|
||||||
if ($states[$st] eq $result) {
|
if ($states[$st] eq $curState) {
|
||||||
$objvalue = ($st == $stc-1) ? $states[0] : $states[$st+1];
|
$newState = ($st == $stc-1) ? $states[0] : $states[$st+1];
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -500,11 +492,11 @@ sub HMCCUDEV_Set ($@)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HMCCU_SetError ($hash, "Current device state doesn't match statevals")
|
return HMCCU_SetError ($hash, "Current device state doesn't match any state value")
|
||||||
if ($objvalue eq '');
|
if ($newState eq '');
|
||||||
|
|
||||||
$rc = HMCCU_SetMultipleDatapoints ($hash,
|
$rc = HMCCU_SetMultipleDatapoints ($hash,
|
||||||
{ "001.$objname" => HMCCU_Substitute ($objvalue, $statevals, 1, undef, '') }
|
{ "001.$ccuif.$ccuaddr:$cc.$cd" => $stateCmds{$newState} }
|
||||||
);
|
);
|
||||||
return HMCCU_SetError ($hash, min(0, $rc));
|
return HMCCU_SetError ($hash, min(0, $rc));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user