2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

55_weco.pm - added some improvements:

- only contact server if any valid attributes defined
- if no attributes found, check every 60 seconds again


git-svn-id: https://svn.fhem.de/fhem/trunk@5516 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2014-04-12 23:13:41 +00:00
parent 0c955f4876
commit 988b3f19f3

View File

@ -105,15 +105,21 @@ sub weco_send($) {
$data .= "&$key=$value"; $data .= "&$key=$value";
} }
Log3 ($name, 4, "weco $name data sent: $data");
$url .= $data;
my $response = GetFileFromURL($url);
Log3 ($name, 4, "weco $name server response: $response");
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
if(defined($data)) {
readingsBulkUpdate($hash, "data", $data); readingsBulkUpdate($hash, "data", $data);
Log3 ($name, 4, "weco $name data sent: $data");
$url .= $data;
my $response = GetFileFromURL($url);
readingsBulkUpdate($hash, "response", $response); readingsBulkUpdate($hash, "response", $response);
Log3 ($name, 4, "weco $name server response: $response");
readingsBulkUpdate($hash, "state", "active"); readingsBulkUpdate($hash, "state", "active");
} else {
Log3 ($name, 4, "weco $name no data");
readingsBulkUpdate($hash, "state", "defined");
$attr{$name}{wecoInterval} = 60;
}
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
InternalTimer(gettimeofday()+$attr{$name}{wecoInterval}, "weco_send", $hash, 0) unless($local == 1); InternalTimer(gettimeofday()+$attr{$name}{wecoInterval}, "weco_send", $hash, 0) unless($local == 1);