diff --git a/fhem/CHANGED b/fhem/CHANGED index 3658cd946..17e016e0a 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - bugfix: 38_netatmo: forecast data check - bugfix: 73_km200.pm: Bugfix for uninitialized values - feature: 73_GasCalculator: New Readings "EnergyXLast" and "EnergyCostXLast" - changed: 98_Hyperion: introducing new attribute hyperionNoSudo diff --git a/fhem/FHEM/38_netatmo.pm b/fhem/FHEM/38_netatmo.pm index 2874d9712..18e77fffc 100644 --- a/fhem/FHEM/38_netatmo.pm +++ b/fhem/FHEM/38_netatmo.pm @@ -2530,118 +2530,120 @@ netatmo_parseForecast($$) readingsEndUpdate($hash,1); } - my $i = 0; - foreach my $forecastdata ( @{$json->{body}{forecastDays}}) + if(defined($json->{body}{forecastDays})) { + my $i = 0; + foreach my $forecastdata ( @{$json->{body}{forecastDays}}) + { - - if(defined($forecastdata->{rain})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_rain", $forecastdata->{rain}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{max_temp})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_temp_max", $forecastdata->{max_temp}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{min_temp})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_temp_min", $forecastdata->{min_temp}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{windangle})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_windangle", $forecastdata->{windangle}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{wind_direction})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_wind_direction", $forecastdata->{wind_direction}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{windgust})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_windgust", $forecastdata->{windgust}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{sun})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_sun", $forecastdata->{sun}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{uv})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_uv", $forecastdata->{uv}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{sunset})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_sunset", FmtDateTime($forecastdata->{sunset}), 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{sunrise})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_sunrise", FmtDateTime($forecastdata->{sunrise}), 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{day_locale})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_day", $forecastdata->{day_locale}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{weather_symbol_day})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_symbol_day", $forecastdata->{weather_symbol_day}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - if(defined($forecastdata->{weather_symbol_night})) - { - readingsBeginUpdate($hash); - $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); - readingsBulkUpdate( $hash, "fc".$i."_symbol_night", $forecastdata->{weather_symbol_night}, 1 ); - $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); - readingsEndUpdate($hash,1); - } - - $i++; - }#foreach forecast + if(defined($forecastdata->{rain})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_rain", $forecastdata->{rain}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{max_temp})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_temp_max", $forecastdata->{max_temp}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{min_temp})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_temp_min", $forecastdata->{min_temp}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{windangle})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_windangle", $forecastdata->{windangle}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{wind_direction})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_wind_direction", $forecastdata->{wind_direction}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{windgust})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_windgust", $forecastdata->{windgust}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{sun})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_sun", $forecastdata->{sun}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{uv})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_uv", $forecastdata->{uv}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{sunset})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_sunset", FmtDateTime($forecastdata->{sunset}), 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{sunrise})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_sunrise", FmtDateTime($forecastdata->{sunrise}), 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{day_locale})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_day", $forecastdata->{day_locale}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{weather_symbol_day})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_symbol_day", $forecastdata->{weather_symbol_day}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + if(defined($forecastdata->{weather_symbol_night})) + { + readingsBeginUpdate($hash); + $hash->{".updateTimestamp"} = FmtDateTime($forecasttime); + readingsBulkUpdate( $hash, "fc".$i."_symbol_night", $forecastdata->{weather_symbol_night}, 1 ); + $hash->{CHANGETIME}[0] = FmtDateTime($forecasttime); + readingsEndUpdate($hash,1); + } + + $i++; + }#foreach forecast + }#defined forecastdays }#ok }#json