Skip to content

Commit

Permalink
Partly code - still missing pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
briis committed Sep 18, 2023
1 parent aedd83a commit d03a00d
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions custom_components/weatherflow_forecast/weather.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Support for WeatherFlow Forecast weather service."""
from __future__ import annotations

from typing import Any

from homeassistant.components.weather import (
ATTR_FORECAST_CONDITION,
ATTR_FORECAST_TIME,
ATTR_WEATHER_DEW_POINT,
ATTR_WEATHER_HUMIDITY,
ATTR_WEATHER_PRESSURE,
ATTR_WEATHER_TEMPERATURE,
ATTR_WEATHER_WIND_BEARING,
ATTR_WEATHER_WIND_GUST_SPEED,
ATTR_WEATHER_WIND_SPEED,
DOMAIN as WEATHER_DOMAIN,
Forecast,
SingleCoordinatorWeatherEntity,
WeatherEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_NAME,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.unit_system import METRIC_SYSTEM

from . import WeatherFlowForecastDataUpdateCoordinator
from .const import DOMAIN, CONF_API_TOKEN, CONF_STATION_ID

DEFAULT_NAME = "WeatherFlow Forecast"

async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add a weather entity from a config_entry."""
coordinator: WeatherFlowForecastDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
entity_registry = er.async_get(hass)

entities = [WeatherFlowWeather(coordinator, config_entry.data,
hass.config.units is METRIC_SYSTEM, False)]

async_add_entities(entities)

class WeatherFlowWeather(SingleCoordinatorWeatherEntity[WeatherFlowForecastDataUpdateCoordinator]):
"""Implementation of a WeatherFlow weather condition."""

_attr_attribution = (
"Weather Forecast from Better Forecast delivered by WeatherFlow"
)
_attr_has_entity_name = True
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS

0 comments on commit d03a00d

Please sign in to comment.