mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
70_PylonLowVoltage: contrib V0.1.4
git-svn-id: https://svn.fhem.de/fhem/trunk@27898 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
39b8dc220c
commit
fea9f5c750
@ -520,10 +520,11 @@ sub startUpdate {
|
|||||||
ualarm ($timeout * 1000000); # ualarm in Mikrosekunden
|
ualarm ($timeout * 1000000); # ualarm in Mikrosekunden
|
||||||
|
|
||||||
$socket = _openSocket ($hash, $timeout, $readings);
|
$socket = _openSocket ($hash, $timeout, $readings);
|
||||||
if (!$socket) { $block ?
|
if (!$socket) {
|
||||||
return ( encode_base64 (Serialize ( {name => $name, readings => $readings} ), "")) :
|
$block ?
|
||||||
return \&finishUpdate ( encode_base64 (Serialize ( {name => $name, readings => $readings} ), ""));
|
return ( encode_base64 (Serialize ( {name => $name, readings => $readings} ), "")) :
|
||||||
}
|
return \&finishUpdate ( encode_base64 (Serialize ( {name => $name, readings => $readings} ), ""));
|
||||||
|
}
|
||||||
|
|
||||||
if (ReadingsAge ($name, "serialNumber", 601) >= 60) { # statische Werte abrufen
|
if (ReadingsAge ($name, "serialNumber", 601) >= 60) { # statische Werte abrufen
|
||||||
if (_callSerialNumber ($hash, $socket, $readings)) { # Abruf serialNumber
|
if (_callSerialNumber ($hash, $socket, $readings)) { # Abruf serialNumber
|
||||||
@ -634,7 +635,7 @@ sub finishUpdate {
|
|||||||
deleteReadingspec ($hash);
|
deleteReadingspec ($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
createReadings ($hash, $readings); # Readings erstellen
|
createReadings ($hash, $success, $readings); # Readings erstellen
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -696,11 +697,9 @@ sub _openSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IO::Socket::Timeout->enable_timeouts_on ($socket); # nur notwendig für read or write timeout
|
IO::Socket::Timeout->enable_timeouts_on ($socket); # nur notwendig für read or write timeout
|
||||||
my $rwto = $timeout - 0.1;
|
|
||||||
$rwto = $rwto <= 0 ? 0.05 : $rwto;
|
|
||||||
|
|
||||||
$socket->read_timeout ($rwto); # Read/Writetimeout immer kleiner als Sockettimeout
|
$socket->read_timeout (0.5); # Read/Writetimeout immer kleiner als Sockettimeout
|
||||||
$socket->write_timeout ($rwto);
|
$socket->write_timeout (0.5);
|
||||||
$socket->autoflush();
|
$socket->autoflush();
|
||||||
|
|
||||||
$hash->{SOCKET} = $socket;
|
$hash->{SOCKET} = $socket;
|
||||||
@ -1294,13 +1293,14 @@ return;
|
|||||||
###############################################################
|
###############################################################
|
||||||
sub createReadings {
|
sub createReadings {
|
||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
|
my $success = shift;
|
||||||
my $readings = shift; # Referenz auf das Hash der zu erstellenden Readings
|
my $readings = shift; # Referenz auf das Hash der zu erstellenden Readings
|
||||||
|
|
||||||
readingsBeginUpdate ($hash);
|
readingsBeginUpdate ($hash);
|
||||||
|
|
||||||
for my $spec (keys %{$readings}) {
|
for my $rdg (keys %{$readings}) {
|
||||||
next if(!defined $readings->{$spec});
|
next if(!defined $readings->{$rdg});
|
||||||
readingsBulkUpdate ($hash, $spec, $readings->{$spec}) if(defined $readings->{$spec});
|
readingsBulkUpdate ($hash, $rdg, $readings->{$rdg}) if($success || $rdg ~~ @blackl);
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsEndUpdate ($hash, 1);
|
readingsEndUpdate ($hash, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user