Skip to content

Commit 580c516

Browse files
committed
Implement the new forecast types
1 parent 4ded7cd commit 580c516

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

.devcontainer/configuration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ logger:
88

99
# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
1010
debugpy:
11-
start: true
12-
wait: true
11+
start: false
12+
wait: false

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Depending on setup, "remoteUser": "vscode", might be preferred to add.
44
{
55
"name": "metnowcast",
6-
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.10",
6+
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11",
77
"postCreateCommand": "scripts/setup",
88
"forwardPorts": [
99
8123

custom_components/metnowcast/weather.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from homeassistant.components.weather import (
2323
Forecast,
2424
WeatherEntity,
25+
WeatherEntityFeature
2526
)
2627
from .met_api import MetApi
2728
from .const import (
@@ -65,6 +66,7 @@ class NowcastWeather(WeatherEntity):
6566
_attr_native_temperature_unit = TEMP_CELSIUS
6667
_attr_native_wind_speed_unit = SPEED_METERS_PER_SECOND
6768
_attr_native_precipitation_unit = LENGTH_MILLIMETERS
69+
_attr_supported_features = WeatherEntityFeature.FORECAST_HOURLY
6870

6971
def __init__(
7072
self,
@@ -177,6 +179,13 @@ def serialize_datetime(self, obj):
177179
return obj.isoformat()
178180
raise TypeError("Type not serializable")
179181

182+
async def async_forecast_hourly(self) -> list[Forecast] | None:
183+
"""Return the hourly forecast in native units.
184+
185+
Only implement this method if `WeatherEntityFeature.FORECAST_HOURLY` is set
186+
"""
187+
return self._forecast
188+
180189
async def async_update(self):
181190
self._forecast = []
182191
self._has_precipitation = False

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
homeassistant==2023.5.4
1+
homeassistant==2023.11.3
22
requests_oauthlib==1.3.1

0 commit comments

Comments
 (0)