fix little bug in weblink creator

This commit is contained in:
Marko Oldenburg
2019-05-14 13:49:34 +02:00
parent 06f0167d79
commit 4c34e181f9

View File

@ -648,16 +648,18 @@ sub Weather_Define($$) {
$hash->{NOTIFYDEV} = "global";
$hash->{fhem}->{interfaces} = "temperature;humidity;wind";
$hash->{LOCATION} =
( ( defined($location) and $location )
$hash->{LOCATION} = (
( defined($location) and $location )
? $location
: AttrVal( 'global', 'latitude', 'error' ) . ','
. AttrVal( 'global', 'longitude', 'error' ) );
. AttrVal( 'global', 'longitude', 'error' )
);
$hash->{INTERVAL} = $interval;
$hash->{LANG} =
( ( defined($lang) and $lang )
$hash->{LANG} = (
( defined($lang) and $lang )
? $lang
: lc( AttrVal( 'global', 'language', 'de' ) ) );
: lc( AttrVal( 'global', 'language', 'de' ) )
);
$hash->{API} = $api;
$hash->{MODEL} = $api;
$hash->{APIKEY} = $apikey;
@ -751,7 +753,9 @@ sub WeatherAsHtmlV($;$$) {
);
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(
'<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,
@ -762,7 +766,8 @@ sub WeatherAsHtmlV($;$$) {
ReadingsVal( $d, "${fc}${i}_high_c", " - " ),
ReadingsVal( $d, "${fc}${i}_wind_condition", " - " )
);
}else{
}
else {
$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>',
$width,
@ -846,7 +851,9 @@ sub WeatherAsHtmlH($;$$) {
ReadingsVal( $d, "humidity", "" )
);
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>',
ReadingsVal( $d, "${fc}${i}_low_c", " - " ) );
}
@ -862,7 +869,9 @@ sub WeatherAsHtmlH($;$$) {
$ret .= sprintf( '<tr><td class="weatherMax">%s</td>',
ReadingsVal( $d, "wind_condition", "" ) );
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>',
ReadingsVal( $d, "${fc}${i}_high_c", " - " ) );
}
@ -904,7 +913,10 @@ sub WeatherCheckOptions($@) {
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 =
( AttrVal( $d, 'forecast', 'none' ) eq 'daily'
? 'd'
: ( AttrVal( $d, 'forecast', 'none' ) eq 'every' ? $f : 'h' ) );
}
$f = 'h' if ( !$f || length($f) > 1 );