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 f1dc42f commit bbb4a7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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": "met_next_6_hours_forecast",
"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
8 changes: 8 additions & 0 deletions custom_components/met_next_6_hours_forecast/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from homeassistant.components.weather import (
Forecast,
WeatherEntity,
WeatherEntityFeature,
)
from .met_api import MetApi
from .const import ATTR_FORECAST_JSON, ATTRIBUTION, DOMAIN, NAME, CONDITIONS_MAP
Expand Down Expand Up @@ -58,6 +59,7 @@ class SixHoursWeather(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 @@ -166,6 +168,12 @@ 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):
"""Retrieve latest state."""
self._raw_data = await self._hass.async_add_executor_job(
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
homeassistant==2023.5.4
homeassistant==2023.11.3

0 comments on commit bbb4a7e

Please sign in to comment.