2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-25 03:39:21 +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:
LeonGaultier 2019-05-14 13:25:11 +00:00
parent b0c122062f
commit 5d33f71232
2 changed files with 65 additions and 52 deletions

View File

@ -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

View File

@ -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;
@ -751,7 +753,9 @@ 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,
@ -762,7 +766,8 @@ 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,
@ -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", " - " ) );
} }
@ -904,7 +913,10 @@ sub WeatherCheckOptions($@) {
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 );