55_GDS.pm: better conditions handling on startup; added condition item RR30; minor bugfixes

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@10318 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen
2015-12-31 16:59:43 +00:00
parent bcc074c93b
commit ba3fd18a34

View File

@@ -42,7 +42,7 @@ use Archive::Extract;
use Net::FTP; use Net::FTP;
use XML::Simple; use XML::Simple;
use Data::Dumper; #use Data::Dumper;
eval "use GDSweblink"; eval "use GDSweblink";
@@ -301,7 +301,9 @@ sub GDS_Define($$$) {
Log3($name, 4, "GDS $name: tempDir=".$tempDir); Log3($name, 4, "GDS $name: tempDir=".$tempDir);
_GDS_addExtension("GDS_CGI","gds","GDS Files"); _GDS_addExtension("GDS_CGI","gds","GDS Files");
$hash->{firstrun} = 1;
retrieveData($hash,'conditions'); retrieveData($hash,'conditions');
delete $hash->{firstrun};
readingsSingleUpdate($hash, 'state', 'active',1); readingsSingleUpdate($hash, 'state', 'active',1);
return undef; return undef;
@@ -388,7 +390,8 @@ sub GDS_Set($@) {
} }
when("conditions"){ when("conditions"){
$attr{$name}{gdsSetCond} = $parameter; #ReadingsVal($name,'c_stationName',undef); CommandAttr(undef, "$name gdsSetCond $parameter");
# $attr{$name}{gdsSetCond} = $parameter; #ReadingsVal($name,'c_stationName',undef);
GDS_GetUpdate($hash,'set conditions'); GDS_GetUpdate($hash,'set conditions');
break; break;
} }
@@ -616,13 +619,24 @@ sub GDS_Attr(@){
my @a = @_; my @a = @_;
my $hash = $defs{$a[1]}; my $hash = $defs{$a[1]};
my ($cmd, $name, $attrName, $attrValue) = @a; my ($cmd, $name, $attrName, $attrValue) = @a;
$attrValue //= '';
my $useUpdate = 0; my $useUpdate = 0;
given($attrName){ given($attrName){
when("gdsSetCond"){ when("gdsSetCond"){
unless ($attrValue eq '' || $cmd eq 'del') { unless ($attrValue eq '' || $cmd eq 'del') {
$attr{$name}{$attrName} = $attrValue; $attr{$name}{$attrName} = $attrValue;
retrieveData($hash,'conditions'); my $diff = time - InternalVal($name,'GDS_CONDITIONS_READ',0);
if ( $diff < 300) {
my @b;
push @b, undef;
push @b, undef;
push @b, $attrValue;
getConditions($hash, "c", @b);
DoTrigger($name,"REREADCONDITIONS",1);
} else {
retrieveData($hash,'conditions');
}
$useUpdate = 1; $useUpdate = 1;
} }
} }
@@ -901,7 +915,6 @@ sub getConditions($$@){
return unless $searchLen; return unless $searchLen;
my ($line, $item, %pos, %alignment, %wx, %cread, $k, $v); my ($line, $item, %pos, %alignment, %wx, %cread, $k, $v);
foreach my $l (@allConditionsData) { foreach my $l (@allConditionsData) {
$line = $l; # save line for further use $line = $l; # save line for further use
if ($l =~ /Station/) { # Header line... find out data positions if ($l =~ /Station/) { # Header line... find out data positions
@@ -915,7 +928,8 @@ sub getConditions($$@){
%alignment = ("Station" => "l", "H\xF6he" => "r", "Luftd." => "r", "TT" => "r", "Tn12" => "r", "Tx12" => "r", %alignment = ("Station" => "l", "H\xF6he" => "r", "Luftd." => "r", "TT" => "r", "Tn12" => "r", "Tx12" => "r",
"Tmin" => "r", "Tmax" => "r", "Tg24" => "r", "Tn24" => "r", "Tm24" => "r", "Tx24" => "r", "SSS24" => "r", "SGLB24" => "r", "Tmin" => "r", "Tmax" => "r", "Tg24" => "r", "Tn24" => "r", "Tm24" => "r", "Tx24" => "r", "SSS24" => "r", "SGLB24" => "r",
"RR1" => "r", "RR12" => "r", "RR24" => "r", "SSS" => "r", "DD" => "r", "FF" => "r", "FX" => "r", "Wetter/Wolken" => "l", "B\xF6en" => "l"); "RR1" => "r", "RR12" => "r", "RR24" => "r", "RR30" => "r", "SSS" => "r", "DD" => "r",
"FF" => "r", "FX" => "r", "Wetter/Wolken" => "l", "B\xF6en" => "l");
foreach $item (@a) { foreach $item (@a) {
Log3($hash, 4, "conditions item: $item"); Log3($hash, 4, "conditions item: $item");
@@ -1319,7 +1333,6 @@ sub _finishedCONDITIONS {
$hash->{GDS_CONDITIONS_READ} = int(time()); $hash->{GDS_CONDITIONS_READ} = int(time());
my $cf = AttrVal($name,'gdsSetCond',0); my $cf = AttrVal($name,'gdsSetCond',0);
return unless $cf; return unless $cf;
# GDS_GetUpdate($hash,1) if $cf;
my @b; my @b;
push @b, undef; push @b, undef;
push @b, undef; push @b, undef;
@@ -1342,7 +1355,6 @@ sub _abortedCONDITIONS {
$hash->{GDS_CONDITIONS_ABORTED} = localtime(time()); $hash->{GDS_CONDITIONS_ABORTED} = localtime(time());
} }
# CapData # CapData
sub _retrieveCAPDATA { sub _retrieveCAPDATA {
my ($hash) = shift; my ($hash) = shift;
@@ -1927,6 +1939,8 @@ sub getListForecastStations($) {
# #
################################################################################################### ###################################################################################################
# #
# 2015-12-31 fixed conditions retrieval on startup
#
# 2015-11-26 fixed wrong region handling # 2015-11-26 fixed wrong region handling
# added gdsAlertsHeadlines() # added gdsAlertsHeadlines()
# #