2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-09 07:44:19 +00:00

59_Weather: fix weblink bug, add extended hourly data format

git-svn-id: https://svn.fhem.de/fhem/trunk@18958 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2019-03-18 12:43:26 +00:00
parent 6815df9da3
commit 1f6aa21e2c
3 changed files with 44 additions and 50 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix/feature: 59_Weather/API's: fix weblink bug, add extended hourly
data format
- feature: 55_DWD_OpenData: - new readings SunRise, SunSet
- SunUp based on upper solar limb
- support warncells beginning with 7

View File

@ -92,13 +92,13 @@ my %wdays_txt_de = (
'Sun' => 'So'
);
my %wdays_txt_nl = (
'Mon' => 'Maa',
'Tue' => 'Din',
'Wed' => 'Woe',
'Thu' => 'Don',
'Fri' => 'Vri',
'Sat' => 'Zat',
'Sun' => 'Zon'
'Mon' => 'Ma',
'Tue' => 'Di',
'Wed' => 'Wo',
'Thu' => 'Do',
'Fri' => 'Vr',
'Sat' => 'Za',
'Sun' => 'Zo'
);
my %wdays_txt_fr = (
'Mon' => 'Lun',
@ -146,7 +146,7 @@ my %status_items_txt_nl = (
0 => "Wind",
1 => "Vochtigheid",
2 => "Temperatuur",
3 => "Direct",
3 => "Actueel",
4 => "Weersvoorspelling voor "
);
my %status_items_txt_fr = (
@ -715,18 +715,8 @@ sub WeatherIconIMGTag($) {
sub WeatherAsHtmlV($;$$) {
my ( $d, $op1, $op2 ) = @_;
my $items = $op2;
my $f = $op1;
if($op1 =~ /[0-9]/g){ $items = $op1; }
if($op2 =~ /[dh]/g){ $f = $op2; }
$f =~ tr/dh/./cd;
$f = "h" if ( !$f || length($f) > 1);
$items =~ tr/0-9/./cd;
$items = 6 if ( !$items );
return "$d is not a Weather instance<br>"
if ( !$defs{$d} || $defs{$d}->{TYPE} ne "Weather" );
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
my $h = $defs{$d};
my $width = int( ICONSCALE * ICONWIDTH );
@ -791,33 +781,16 @@ sub WeatherAsHtmlV($;$$) {
sub WeatherAsHtml($;$$) {
my ( $d, $op1, $op2 ) = @_;
my $items = $op2;
my $f = $op1;
if($op1 =~ /[0-9]/g){ $items = $op1; }
if($op2 =~ /[dh]/g){ $f = $op2; }
$f =~ tr/dh/./cd;
$f = "h" if ( !$f || length($f) > 1);
$items =~ tr/0-9/./cd;
$items = 6 if ( !$items );
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
WeatherAsHtmlV( $d, $f, $items );
}
sub WeatherAsHtmlH($;$$) {
my ( $d, $op1, $op2 ) = @_;
my $items = $op2;
my $f = $op1;
if($op1 =~ /[0-9]/g){ $items = $op1; }
if($op2 =~ /[dh]/g){ $f = $op2; }
$f =~ tr/dh/./cd;
$f = "h" if ( !$f || length($f) > 1);
$items =~ tr/0-9/./cd;
$items = 6 if ( !$items );
return "$d is not a Weather instance<br>"
if ( !$defs{$d} || $defs{$d}->{TYPE} ne "Weather" );
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
my $h = $defs{$d};
my $width = int( ICONSCALE * ICONWIDTH );
@ -902,15 +875,8 @@ sub WeatherAsHtmlH($;$$) {
sub WeatherAsHtmlD($;$$) {
my ( $d, $op1, $op2 ) = @_;
my $items = $op2;
my $f = $op1;
if($op1 =~ /[0-9]/g){ $items = $op1; }
if($op2 =~ /[dh]/g){ $f = $op2; }
$f =~ tr/dh/./cd;
$f = "h" if ( !$f || length($f) > 1);
$items =~ tr/0-9/./cd;
$items = 6 if ( !$items );
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
if ($FW_ss) {
WeatherAsHtmlV( $d, $f , $items);
@ -920,6 +886,32 @@ sub WeatherAsHtmlD($;$$) {
}
}
sub WeatherCheckOptions($@) {
my ($d,$op1,$op2) = @_;
my $items = $op2;
my $f = $op1;
if( defined($op1) and $op1 and $op1 =~ /[0-9]/g){ $items = $op1; }
if( defined($op2) and $op2 and $op2 =~ /[dh]/g){ $f = $op2; }
$f =~ tr/dh/./cd if ( defined $f and $f );
$items =~ tr/0-9/./cd if (defined($items) and $items );
$items = 6 if ( !$items );
return "$d is not a Weather instance<br>"
if ( !$defs{$d} || $defs{$d}->{TYPE} ne "Weather" );
if ( AttrVal($d,'forecast','none') ne 'none' ) {
$f = ( AttrVal($d,'forecast','none') eq 'daily' ? 'd' : 'h' );
}
$f = 'h' if ( !$f || length($f) > 1);
return ($f,$items);
}
#####################################
1;

View File

@ -48,7 +48,7 @@ use constant DEMODATA => '{"latitude":50.112,"longitude":8.686,"timezone":"Europ
use constant URL => 'https://api.darksky.net/forecast/';
use constant VERSION => '0.2.7';
use constant VERSION => '0.2.8';
my %codes = (
'clear-day' => 32,
@ -166,7 +166,7 @@ sub _RetrieveDataFromDarkSky($) {
. $self->{long}
. '?lang='
. $self->{lang}
. '&units=auto';
. '&units=auto&extend=hourly';
if ( lc($self->{key}) eq 'demo' )
{ _RetrieveDataFinished($paramRef,undef,DEMODATA); }