From 001dda63450cd971902cb226b9176481d149ad6a Mon Sep 17 00:00:00 2001 From: G Johansson Date: Mon, 7 Aug 2023 09:42:20 +0200 Subject: [PATCH] Fix weather entities with update_before_add (#97950) Fix weather entities update_before_add --- homeassistant/components/weather/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/weather/__init__.py b/homeassistant/components/weather/__init__.py index f0c32f2d8cc..bfad18cb84a 100644 --- a/homeassistant/components/weather/__init__.py +++ b/homeassistant/components/weather/__init__.py @@ -1048,6 +1048,12 @@ class WeatherEntity(Entity): self, forecast_types: Iterable[Literal["daily", "hourly", "twice_daily"]] | None ) -> None: """Push updated forecast to all listeners.""" + if not hasattr(self, "_forecast_listeners"): + # Required for entities initiated with `update_before_add` + # as `self._forecast_listeners` has not yet been set. + # `async_internal_added_to_hass()` will execute once entity has been added. + return + if forecast_types is None: forecast_types = {"daily", "hourly", "twice_daily"} for forecast_type in forecast_types: