Skip to content

Commit a0e7569

Browse files
author
tsunglung
committed
Fixed the excpetion and the missing low temperature in daily forecast
1 parent 13c00f2 commit a0e7569

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

custom_components/opencwb/weather.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
weather_coordinator: WeatherUpdateCoordinator,
5959
):
6060
"""Initialize the sensor."""
61+
super().__init__(weather_coordinator)
6162
self._attr_name = name
6263
self._attr_unique_id = unique_id
6364
self._weather_coordinator = weather_coordinator

custom_components/opencwb/weather_update_coordinator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,16 @@ def _convert_forecast(self, entry):
203203
}
204204

205205
temperature_dict = entry.temperature("celsius")
206-
if "max" in temperature_dict and "min" in temperature_dict:
206+
if temperature_dict.get("max") and temperature_dict.get("min"):
207207
forecast[ATTR_FORECAST_TEMP] = entry.temperature(
208208
"celsius").get("max")
209209
forecast[ATTR_FORECAST_TEMP_LOW] = entry.temperature(
210210
"celsius").get("min")
211+
elif temperature_dict.get("temp_max") and temperature_dict.get("temp_min"):
212+
forecast[ATTR_FORECAST_TEMP] = entry.temperature(
213+
"celsius").get("temp_max")
214+
forecast[ATTR_FORECAST_TEMP_LOW] = entry.temperature(
215+
"celsius").get("temp_min")
211216
else:
212217
forecast[ATTR_FORECAST_TEMP] = entry.temperature(
213218
"celsius").get("temp")

0 commit comments

Comments
 (0)