Skip to content

Commit

Permalink
Merge pull request #204 from evilmarty/main
Browse files Browse the repository at this point in the history
Fix forecasts
  • Loading branch information
Makin-Things committed Jan 2, 2024
2 parents b9563d8 + 6ee25be commit 420766a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions custom_components/bureau_of_meteorology/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import iso8601
import pytz
from homeassistant.components.weather import Forecast, WeatherEntity
from homeassistant.components.weather import Forecast, WeatherEntity, WeatherEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import SPEED_KILOMETERS_PER_HOUR, TEMP_CELSIUS
from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -86,7 +86,7 @@ async def async_forecast_daily(self) -> list[Forecast]:
native_precipitation=data["rain_amount_max"],
precipitation_probability=data["rain_chance"],
)
for data in self.collector.daily_forecasts_data["data"].values()
for data in self.collector.daily_forecasts_data["data"]
]

async def async_forecast_hourly(self) -> list[Forecast]:
Expand All @@ -104,9 +104,14 @@ async def async_forecast_hourly(self) -> list[Forecast]:
humidity=data["relative_humidity"],
uv=data["uv"],
)
for data in self.collector.hourly_forecasts_data["data"].values()
for data in self.collector.hourly_forecasts_data["data"]
]

@property
def supported_features(self) -> WeatherEntityFeature:
"""Determine supported features based on available data sets reported by WeatherKit."""
return WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY

@callback
def _update_callback(self) -> None:
"""Load data from integration."""
Expand Down Expand Up @@ -179,6 +184,10 @@ async def async_forecast_hourly(self) -> list[Forecast]:
# Don't implement this feature for this entity
raise NotImplementedError

@property
def supported_features(self):
return WeatherEntityFeature.FORECAST_DAILY

@property
def name(self):
"""Return the name."""
Expand All @@ -201,6 +210,10 @@ async def async_forecast_daily(self) -> list[Forecast]:
# Don't implement this feature for this entity
raise NotImplementedError

@property
def supported_features(self):
return WeatherEntityFeature.FORECAST_HOURLY

@property
def name(self):
"""Return the name."""
Expand Down

0 comments on commit 420766a

Please sign in to comment.