Skip to content

Commit

Permalink
Fixed the excpetion and the missing low temperature in daily forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunglung committed Mar 9, 2024
1 parent 13c00f2 commit f56f1e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions custom_components/opencwb/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
weather_coordinator: WeatherUpdateCoordinator,
):
"""Initialize the sensor."""
super().__init__(weather_coordinator)
self._attr_name = name
self._attr_unique_id = unique_id
self._weather_coordinator = weather_coordinator
Expand Down
9 changes: 7 additions & 2 deletions custom_components/opencwb/weather_update_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,22 @@ def _convert_forecast(self, entry):
),
ATTR_API_FORECAST_CLOUDS: entry.clouds,
ATTR_API_FORECAST_FEELS_LIKE_TEMPERATURE: entry.temperature("celsius").get(
"feels_like_day"
"feels_like"
),
ATTR_API_FORECAST_HUMIDITY: entry.humidity,
}

temperature_dict = entry.temperature("celsius")
if "max" in temperature_dict and "min" in temperature_dict:
if temperature_dict.get("max") and temperature_dict.get("min"):
forecast[ATTR_FORECAST_TEMP] = entry.temperature(
"celsius").get("max")
forecast[ATTR_FORECAST_TEMP_LOW] = entry.temperature(
"celsius").get("min")
elif temperature_dict.get("temp_max") and temperature_dict.get("temp_min"):
forecast[ATTR_FORECAST_TEMP] = entry.temperature(
"celsius").get("temp_max")
forecast[ATTR_FORECAST_TEMP_LOW] = entry.temperature(
"celsius").get("temp_min")
else:
forecast[ATTR_FORECAST_TEMP] = entry.temperature(
"celsius").get("temp")
Expand Down

0 comments on commit f56f1e6

Please sign in to comment.