34_SWAP.pm: added random delay to initial statusRequest to avoid collisions of the response messages

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@8401 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme1968
2015-04-08 16:23:25 +00:00
parent 7c1dfc1021
commit 1f65ee9f03

View File

@@ -803,6 +803,8 @@ SWAP_regName($$$)
{
my ($rid, $ep, $endpoint) = @_;
$ep = "0$ep" if( length($ep) == 0 );
if( !defined($endpoint) ) {
return $rid if( $ep == 0 && !defined($endpoint->{position}) );
return $rid .'.'. $ep;
@@ -1023,7 +1025,8 @@ SWAP_Parse($$)
$rhash->{product} = $products->{$productcode} if( defined($productcode) && defined($products->{$productcode} ) );
if( $first ) {
SWAP_Set( $rhash, $rname, "statusRequest" );
my $time = 1+rand(5);
fhem( "sleep $time; set $rname statusRequest" );
} else {
SWAP_Send($rhash, $rhash->{addr}, QUERY, "01" );
SWAP_Send($rhash, $rhash->{addr}, QUERY, "02" );