+ if ($ts >= $ld->{last_hour} + 1800) {
+ $h{Pressure_Trend} = unpack("C", substr $blk,3,1);
+ $h{Pressure_Trend_txt} = $bar_trend{$h{Pressure_Trend}};
+ $h{Batt_TX_OK} = (unpack("C", substr $blk,86,1)+0) ^ 1;
+ $h{Batt_Console} = nearest(0.01, unpack("s", substr $blk,87,2) * 0.005859375);
+ $h{Forecast_Icon} = unpack("C", substr $blk,89,1);
+ $h{Forecast_Rule} = unpack("C", substr $blk,90,1);
+ $h{Sunrise} = sprintf( "%04d", unpack("S", substr $blk,91,2) );
+ $h{Sunrise} =~ s/(\d{2})(\d{2})/$1:$2/;
+ $h{Sunset} = sprintf( "%04d", unpack("S", substr $blk,93,2) );
+ $h{Sunset} =~ s/(\d{2})(\d{2})/$1:$2/;
+
+ if ($loop_count) { # i.e not the first
+ my $a = wind_average(scalar @{$ld->{wind_hour}} ? @{$ld->{wind_hour}} : {w => $h{Wind}, d => $h{Dir}});
+
+ $h{Wind_1h} = nearest(0.1, $a->{w});
+ $h{Dir_1h} = nearest(0.1, $a->{d});
+
+ $a = wind_average(@{$ld->{wind_min}});
+ $h{Wind_1m} = nearest(0.1, $a->{w});
+ $h{Dir_1m} = nearest(1, $a->{d});
+
+ ($h{Rain_1m}, $h{Rain_1h}, $h{Rain_24h}) = calc_rain($rain);
+
+ }
+ $ld->{last_rain_min} = $ld->{last_rain_hour} = $rain;
+ $h{Temp_Out_Max} = $ld->{Temp_Out_Max};
+ $h{Temp_Out_Max_T} = $ld->{Temp_Out_Max_T};
+ $h{Temp_Out_Min} = $ld->{Temp_Out_Min};
+ $h{Temp_Out_Min_T} = $ld->{Temp_Out_Min_T};
+ $h{Wind_Max} = $ld->{Wind_Max};
+ $h{Wind_Max_T} = $ld->{Wind_Max_T};
+
+ $last_hour_h = {%h};
+ $s = genstr($ts, 'h', \%h);
+ $ld->{lasthour_h} = $s;
+
+ $ld->{last_hour} = int($ts/1800)*1800;
+ $ld->{last_min} = int($ts/60)*60;
+ @{$ld->{wind_hour}} = ();
+ @{$ld->{wind_min}} = ();
+
+ if ($s) {
+ output_str($s, 1);
+ push @last5daysh, $s;
+ shift @last5daysh if @last5daysh > 5*24;
+ }
+ ++$writeld;