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 a0e7569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion custom_components/opencwb/weather_update_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ def _convert_forecast(self, entry):
}

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 a0e7569

Please sign in to comment.