Skip to content

Commit

Permalink
Implement the new forecast types
Browse files Browse the repository at this point in the history
  • Loading branch information
toringer committed Nov 26, 2023
1 parent 4ded7cd commit 580c516
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ logger:

# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
start: true
wait: true
start: false
wait: false
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Depending on setup, "remoteUser": "vscode", might be preferred to add.
{
"name": "metnowcast",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.10",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
8123
Expand Down
9 changes: 9 additions & 0 deletions custom_components/metnowcast/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from homeassistant.components.weather import (
Forecast,
WeatherEntity,
WeatherEntityFeature
)
from .met_api import MetApi
from .const import (
Expand Down Expand Up @@ -65,6 +66,7 @@ class NowcastWeather(WeatherEntity):
_attr_native_temperature_unit = TEMP_CELSIUS
_attr_native_wind_speed_unit = SPEED_METERS_PER_SECOND
_attr_native_precipitation_unit = LENGTH_MILLIMETERS
_attr_supported_features = WeatherEntityFeature.FORECAST_HOURLY

def __init__(
self,
Expand Down Expand Up @@ -177,6 +179,13 @@ def serialize_datetime(self, obj):
return obj.isoformat()
raise TypeError("Type not serializable")

async def async_forecast_hourly(self) -> list[Forecast] | None:
"""Return the hourly forecast in native units.
Only implement this method if `WeatherEntityFeature.FORECAST_HOURLY` is set
"""
return self._forecast

async def async_update(self):
self._forecast = []
self._has_precipitation = False
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
homeassistant==2023.5.4
homeassistant==2023.11.3
requests_oauthlib==1.3.1

0 comments on commit 580c516

Please sign in to comment.