mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-28 02:44:53 +00:00
59_Weather: fix little bug then create weblink
git-svn-id: https://svn.fhem.de/fhem/trunk@19385 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b0c122062f
commit
5d33f71232
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- bugfix: 59_Weather: fix little bug then create weblink
|
||||||
- bugfix: 88_HMCCU: Flag for disabling initial device update
|
- bugfix: 88_HMCCU: Flag for disabling initial device update
|
||||||
- bugfix: 10_MYSENSORS_DEVICE: prevent fhem crashing by ack timeout
|
- bugfix: 10_MYSENSORS_DEVICE: prevent fhem crashing by ack timeout
|
||||||
at higher verobse levels
|
at higher verobse levels
|
||||||
|
@ -608,8 +608,8 @@ sub Weather_Notify($$) {
|
|||||||
Weather_RearmTimer( $hash, gettimeofday() + $delay );
|
Weather_RearmTimer( $hash, gettimeofday() + $delay );
|
||||||
|
|
||||||
### quick run GetUpdate then Demo
|
### quick run GetUpdate then Demo
|
||||||
Weather_GetUpdate( $hash )
|
Weather_GetUpdate($hash)
|
||||||
if ( defined($hash->{APIKEY}) and lc($hash->{APIKEY}) eq 'demo' );
|
if ( defined( $hash->{APIKEY} ) and lc( $hash->{APIKEY} ) eq 'demo' );
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -648,16 +648,18 @@ sub Weather_Define($$) {
|
|||||||
|
|
||||||
$hash->{NOTIFYDEV} = "global";
|
$hash->{NOTIFYDEV} = "global";
|
||||||
$hash->{fhem}->{interfaces} = "temperature;humidity;wind";
|
$hash->{fhem}->{interfaces} = "temperature;humidity;wind";
|
||||||
$hash->{LOCATION} =
|
$hash->{LOCATION} = (
|
||||||
( ( defined($location) and $location )
|
( defined($location) and $location )
|
||||||
? $location
|
? $location
|
||||||
: AttrVal( 'global', 'latitude', 'error' ) . ','
|
: AttrVal( 'global', 'latitude', 'error' ) . ','
|
||||||
. AttrVal( 'global', 'longitude', 'error' ) );
|
. AttrVal( 'global', 'longitude', 'error' )
|
||||||
|
);
|
||||||
$hash->{INTERVAL} = $interval;
|
$hash->{INTERVAL} = $interval;
|
||||||
$hash->{LANG} =
|
$hash->{LANG} = (
|
||||||
( ( defined($lang) and $lang )
|
( defined($lang) and $lang )
|
||||||
? $lang
|
? $lang
|
||||||
: lc( AttrVal( 'global', 'language', 'de' ) ) );
|
: lc( AttrVal( 'global', 'language', 'de' ) )
|
||||||
|
);
|
||||||
$hash->{API} = $api;
|
$hash->{API} = $api;
|
||||||
$hash->{MODEL} = $api;
|
$hash->{MODEL} = $api;
|
||||||
$hash->{APIKEY} = $apikey;
|
$hash->{APIKEY} = $apikey;
|
||||||
@ -716,7 +718,7 @@ sub WeatherIconIMGTag($) {
|
|||||||
sub WeatherAsHtmlV($;$$) {
|
sub WeatherAsHtmlV($;$$) {
|
||||||
my ( $d, $op1, $op2 ) = @_;
|
my ( $d, $op1, $op2 ) = @_;
|
||||||
|
|
||||||
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
|
my ( $f, $items ) = WeatherCheckOptions( $d, $op1, $op2 );
|
||||||
|
|
||||||
my $h = $defs{$d};
|
my $h = $defs{$d};
|
||||||
my $width = int( ICONSCALE * ICONWIDTH );
|
my $width = int( ICONSCALE * ICONWIDTH );
|
||||||
@ -751,9 +753,11 @@ sub WeatherAsHtmlV($;$$) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for ( my $i = 1 ; $i < $items ; $i++ ) {
|
for ( my $i = 1 ; $i < $items ; $i++ ) {
|
||||||
if(defined($h->{READINGS}->{"${fc}${i}_low_c"}) and $h->{READINGS}->{"${fc}${i}_low_c"}){
|
if ( defined( $h->{READINGS}->{"${fc}${i}_low_c"} )
|
||||||
|
and $h->{READINGS}->{"${fc}${i}_low_c"} )
|
||||||
|
{
|
||||||
$ret .= sprintf(
|
$ret .= sprintf(
|
||||||
'<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherMin">min %s°C</span> <span class="weatherMax">max %s°C</span><br>%s</td></tr>',
|
'<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherMin">min %s°C</span> <span class="weatherMax">max %s°C</span><br>%s</td></tr>',
|
||||||
$width,
|
$width,
|
||||||
WeatherIconIMGTag( ReadingsVal( $d, "${fc}${i}_icon", "" ) ),
|
WeatherIconIMGTag( ReadingsVal( $d, "${fc}${i}_icon", "" ) ),
|
||||||
ReadingsVal( $d, "${fc}${i}_day_of_week", "" ),
|
ReadingsVal( $d, "${fc}${i}_day_of_week", "" ),
|
||||||
@ -762,9 +766,10 @@ sub WeatherAsHtmlV($;$$) {
|
|||||||
ReadingsVal( $d, "${fc}${i}_high_c", " - " ),
|
ReadingsVal( $d, "${fc}${i}_high_c", " - " ),
|
||||||
ReadingsVal( $d, "${fc}${i}_wind_condition", " - " )
|
ReadingsVal( $d, "${fc}${i}_wind_condition", " - " )
|
||||||
);
|
);
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
$ret .= sprintf(
|
$ret .= sprintf(
|
||||||
'<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherTemp"> %s°C</span><br>%s</td></tr>',
|
'<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherTemp"> %s°C</span><br>%s</td></tr>',
|
||||||
$width,
|
$width,
|
||||||
WeatherIconIMGTag( ReadingsVal( $d, "${fc}${i}_icon", "" ) ),
|
WeatherIconIMGTag( ReadingsVal( $d, "${fc}${i}_icon", "" ) ),
|
||||||
ReadingsVal( $d, "${fc}${i}_day_of_week", "" ),
|
ReadingsVal( $d, "${fc}${i}_day_of_week", "" ),
|
||||||
@ -782,7 +787,7 @@ sub WeatherAsHtmlV($;$$) {
|
|||||||
sub WeatherAsHtml($;$$) {
|
sub WeatherAsHtml($;$$) {
|
||||||
my ( $d, $op1, $op2 ) = @_;
|
my ( $d, $op1, $op2 ) = @_;
|
||||||
|
|
||||||
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
|
my ( $f, $items ) = WeatherCheckOptions( $d, $op1, $op2 );
|
||||||
|
|
||||||
WeatherAsHtmlV( $d, $f, $items );
|
WeatherAsHtmlV( $d, $f, $items );
|
||||||
}
|
}
|
||||||
@ -790,7 +795,7 @@ sub WeatherAsHtml($;$$) {
|
|||||||
sub WeatherAsHtmlH($;$$) {
|
sub WeatherAsHtmlH($;$$) {
|
||||||
my ( $d, $op1, $op2 ) = @_;
|
my ( $d, $op1, $op2 ) = @_;
|
||||||
|
|
||||||
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
|
my ( $f, $items ) = WeatherCheckOptions( $d, $op1, $op2 );
|
||||||
|
|
||||||
my $h = $defs{$d};
|
my $h = $defs{$d};
|
||||||
my $width = int( ICONSCALE * ICONWIDTH );
|
my $width = int( ICONSCALE * ICONWIDTH );
|
||||||
@ -846,7 +851,9 @@ sub WeatherAsHtmlH($;$$) {
|
|||||||
ReadingsVal( $d, "humidity", "" )
|
ReadingsVal( $d, "humidity", "" )
|
||||||
);
|
);
|
||||||
for ( my $i = 1 ; $i < $items ; $i++ ) {
|
for ( my $i = 1 ; $i < $items ; $i++ ) {
|
||||||
if(defined($h->{READINGS}->{"${fc}${i}_low_c"}) and $h->{READINGS}->{"${fc}${i}_low_c"}){
|
if ( defined( $h->{READINGS}->{"${fc}${i}_low_c"} )
|
||||||
|
and $h->{READINGS}->{"${fc}${i}_low_c"} )
|
||||||
|
{
|
||||||
$ret .= sprintf( '<td class="weatherMin">min %s°C</td>',
|
$ret .= sprintf( '<td class="weatherMin">min %s°C</td>',
|
||||||
ReadingsVal( $d, "${fc}${i}_low_c", " - " ) );
|
ReadingsVal( $d, "${fc}${i}_low_c", " - " ) );
|
||||||
}
|
}
|
||||||
@ -862,7 +869,9 @@ sub WeatherAsHtmlH($;$$) {
|
|||||||
$ret .= sprintf( '<tr><td class="weatherMax">%s</td>',
|
$ret .= sprintf( '<tr><td class="weatherMax">%s</td>',
|
||||||
ReadingsVal( $d, "wind_condition", "" ) );
|
ReadingsVal( $d, "wind_condition", "" ) );
|
||||||
for ( my $i = 1 ; $i < $items ; $i++ ) {
|
for ( my $i = 1 ; $i < $items ; $i++ ) {
|
||||||
if(defined($h->{READINGS}->{"${fc}${i}_high_c"}) and $h->{READINGS}->{"${fc}${i}_high_c"}){
|
if ( defined( $h->{READINGS}->{"${fc}${i}_high_c"} )
|
||||||
|
and $h->{READINGS}->{"${fc}${i}_high_c"} )
|
||||||
|
{
|
||||||
$ret .= sprintf( '<td class="weatherMax">max %s°C</td>',
|
$ret .= sprintf( '<td class="weatherMax">max %s°C</td>',
|
||||||
ReadingsVal( $d, "${fc}${i}_high_c", " - " ) );
|
ReadingsVal( $d, "${fc}${i}_high_c", " - " ) );
|
||||||
}
|
}
|
||||||
@ -876,40 +885,43 @@ sub WeatherAsHtmlH($;$$) {
|
|||||||
sub WeatherAsHtmlD($;$$) {
|
sub WeatherAsHtmlD($;$$) {
|
||||||
my ( $d, $op1, $op2 ) = @_;
|
my ( $d, $op1, $op2 ) = @_;
|
||||||
|
|
||||||
my ($f,$items) = WeatherCheckOptions($d,$op1,$op2);
|
my ( $f, $items ) = WeatherCheckOptions( $d, $op1, $op2 );
|
||||||
|
|
||||||
if ($FW_ss) {
|
if ($FW_ss) {
|
||||||
WeatherAsHtmlV( $d, $f , $items);
|
WeatherAsHtmlV( $d, $f, $items );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WeatherAsHtmlH( $d, $f , $items);
|
WeatherAsHtmlH( $d, $f, $items );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub WeatherCheckOptions($@) {
|
sub WeatherCheckOptions($@) {
|
||||||
my ($d,$op1,$op2) = @_;
|
my ( $d, $op1, $op2 ) = @_;
|
||||||
|
|
||||||
my $items = $op2;
|
my $items = $op2;
|
||||||
my $f = $op1;
|
my $f = $op1;
|
||||||
|
|
||||||
if( defined($op1) and $op1 and $op1 =~ /[0-9]/g){ $items = $op1; }
|
if ( defined($op1) and $op1 and $op1 =~ /[0-9]/g ) { $items = $op1; }
|
||||||
if( defined($op2) and $op2 and $op2 =~ /[dh]/g){ $f = $op2; }
|
if ( defined($op2) and $op2 and $op2 =~ /[dh]/g ) { $f = $op2; }
|
||||||
|
|
||||||
$f =~ tr/dh/./cd if ( defined $f and $f );
|
$f =~ tr/dh/./cd if ( defined $f and $f );
|
||||||
$items =~ tr/0-9/./cd if (defined($items) and $items );
|
$items =~ tr/0-9/./cd if ( defined($items) and $items );
|
||||||
|
|
||||||
$items = 6 if ( !$items );
|
$items = 6 if ( !$items );
|
||||||
|
|
||||||
return "$d is not a Weather instance<br>"
|
return "$d is not a Weather instance<br>"
|
||||||
if ( !$defs{$d} || $defs{$d}->{TYPE} ne "Weather" );
|
if ( !$defs{$d} || $defs{$d}->{TYPE} ne "Weather" );
|
||||||
|
|
||||||
if ( AttrVal($d,'forecast','none') ne 'none' ) {
|
if ( AttrVal( $d, 'forecast', 'none' ) ne 'none' ) {
|
||||||
$f = ( AttrVal($d,'forecast','none') eq 'daily' ? 'd' : 'h' );
|
$f =
|
||||||
|
( AttrVal( $d, 'forecast', 'none' ) eq 'daily'
|
||||||
|
? 'd'
|
||||||
|
: ( AttrVal( $d, 'forecast', 'none' ) eq 'every' ? $f : 'h' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$f = 'h' if ( !$f || length($f) > 1);
|
$f = 'h' if ( !$f || length($f) > 1 );
|
||||||
|
|
||||||
return ($f,$items);
|
return ( $f, $items );
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user