34_SWAP.pm: fixed my $var = ... if( ... );

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@23870 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2021-03-01 08:27:35 +00:00
parent 6af4ff5212
commit 27b31040ca

View File

@ -642,7 +642,8 @@ Log 3, $value;
}
} elsif( $cmd eq "readDeviceXML" ) {
my $productcode = $attr{$name}{ProductCode} if( defined($attr{$name}{ProductCode} ) );
my $productcode;
$productcode = $attr{$name}{ProductCode} if( defined($attr{$name}{ProductCode} ) );
if( defined($products->{$productcode} ) ) {
SWAP_readDeviceXML( $hash, $productcode );
$hash->{product} = $products->{$productcode} if( defined($productcode) && defined($products->{$productcode} ) );
@ -1171,7 +1172,8 @@ SWAP_ProcessCmdStack($)
my $sent;
if($hash->{cmdStack}) {
if(@{$hash->{cmdStack}}) {
my $params = shift @{$hash->{cmdStack}};
my $params;
$params = shift @{$hash->{cmdStack}};
SWAP_Send($hash, $params->[0], $params->[1], $params->[2], $params->[3]);
$sent = 1;
$hash->{SWAP_CMDsPending} = scalar @{$hash->{cmdStack}}." CMDs_pending";
@ -1232,8 +1234,10 @@ SWAP_Attr(@)
my $i = 0;
foreach my $endpoint ( @{$register->{endpoints}} ) {
if( $endpoint->{units} ) {
my $factor = $endpoint->{units}->[0]->{factor} if( defined($endpoint->{units}->[0]->{factor}) );
my $offset = $endpoint->{units}->[0]->{offset} if( defined($endpoint->{units}->[0]->{offset}) );
my $factor;
$factor = $endpoint->{units}->[0]->{factor} if( defined($endpoint->{units}->[0]->{factor}) );
my $offset;
$offset = $endpoint->{units}->[0]->{offset} if( defined($endpoint->{units}->[0]->{offset}) );
my $func = "";
$func .= "*$factor" if( defined($factor) && $factor != 1 );
$func .= "+$offset" if( defined($offset) && $offset > 0 );