Skip to content

Commit f56f1e6

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

2 files changed

Lines changed: 8 additions & 2 deletions

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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,22 @@ def _convert_forecast(self, entry):
197197
),
198198
ATTR_API_FORECAST_CLOUDS: entry.clouds,
199199
ATTR_API_FORECAST_FEELS_LIKE_TEMPERATURE: entry.temperature("celsius").get(
200-
"feels_like_day"
200+
"feels_like"
201201
),
202202
ATTR_API_FORECAST_HUMIDITY: entry.humidity,
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)