change day_of_week processing

This commit is contained in:
Marko Oldenburg 2019-01-12 07:34:54 +01:00
parent 76a995a95d
commit 4aa222ba33
3 changed files with 5 additions and 5 deletions

View File

@ -405,8 +405,8 @@ sub Weather_WriteReadings($$) {
readingsBulkUpdate($hash, $f.$r, $v)
if ( ref($dataRef->{$r}) ne 'HASH' and ref($dataRef->{$r}) ne 'ARRAY' );
}
# readingsBulkUpdate($hash, $f . "day_of_week", $wdays_txt_i18n{$fc->{day}});
readingsBulkUpdate($hash, $f . 'icon', $iconlist[$dataRef->{forecast}->{hourly}[$i-1]{code}]);
if ( defined($dataRef->{forecast}->{hourly}[$i-1]{wind_direction})
and $dataRef->{forecast}->{hourly}[$i-1]{wind_direction}
and defined($dataRef->{forecast}->{hourly}[$i-1]{wind_speed})
@ -416,7 +416,6 @@ sub Weather_WriteReadings($$) {
my $wdir= degrees_to_direction($dataRef->{forecast}->{hourly}[$i-1]{wind_direction}, @directions_txt_i18n);
readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{hourly}[$i-1]{wind_speed} . ' km/h');
}
readingsBulkUpdate($hash, $f . 'day_of_week', ( length((split(',', $dataRef->{forecast}->{hourly}[$i-1]{pubDate}))[0]) > 2 ? $wdays_txt_i18n{substr($dataRef->{forecast}->{hourly}[$i-1]{pubDate},0,3)} : substr($dataRef->{forecast}->{hourly}[$i-1]{pubDate},0,2) ) );
}
}
@ -433,8 +432,8 @@ sub Weather_WriteReadings($$) {
readingsBulkUpdate($hash, $f.$r, $v)
if ( ref($dataRef->{$r}) ne 'HASH' and ref($dataRef->{$r}) ne 'ARRAY' );
}
# readingsBulkUpdate($hash, $f . "day_of_week", $wdays_txt_i18n{$fc->{day}});
readingsBulkUpdate($hash, $f . 'icon', $iconlist[$dataRef->{forecast}->{daily}[$i-1]{code}]);
if ( defined($dataRef->{forecast}->{daily}[$i-1]{wind_direction})
and $dataRef->{forecast}->{daily}[$i-1]{wind_direction}
and defined($dataRef->{forecast}->{daily}[$i-1]{wind_speed})
@ -444,7 +443,6 @@ sub Weather_WriteReadings($$) {
my $wdir= degrees_to_direction($dataRef->{forecast}->{daily}[$i-1]{wind_direction}, @directions_txt_i18n);
readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{daily}[$i-1]{wind_speed} . ' km/h');
}
readingsBulkUpdate($hash, $f . 'day_of_week', ( length((split(',', $dataRef->{forecast}->{daily}[$i-1]{pubDate}))[0]) > 2 ? $wdays_txt_i18n{substr($dataRef->{forecast}->{daily}[$i-1]{pubDate},0,3)} : substr($dataRef->{forecast}->{daily}[$i-1]{pubDate},0,2) ) );
}
}
}
@ -678,7 +676,7 @@ sub WeatherAsHtmlV($;$)
my ($d,$items) = @_;
$d = "<none>" if(!$d);
$items = 10 if( !$items );
$items = 9 if( !$items );
return "$d is not a Weather instance<br>"
if(!$defs{$d} || $defs{$d}->{TYPE} ne "Weather");

View File

@ -273,6 +273,7 @@ sub _ProcessingRetrieveData($$) {
$data->{daily}->{data}->[$i]->{'time'}
)
),
'day_of_week' => strftime("%a",localtime($data->{daily}->{data}->[$i]->{'time'})),
'low_c' => int(
sprintf( "%.1f",
$data->{daily}->{data}->[$i]

View File

@ -340,6 +340,7 @@ sub _ProcessingRetrieveData($$) {
( $data->{list}->[$i]->{dt} ) - 3600
)
),
'day_of_week' => strftime("%a",localtime(( $data->{list}->[$i]->{dt} ) - 3600)),
'temperature' => int(
sprintf(
"%.1f",