Skip to content

Commit

Permalink
Update to open-meteo-solar-forecast 0.1.18
Browse files Browse the repository at this point in the history
- Improves cell temperature calculation (should reduce over/under-estimations)
- Add damping support for morning and/or evening

Signed-off-by: rany <ranygh@riseup.net>
  • Loading branch information
rany2 committed Aug 19, 2024
1 parent 2766611 commit ee2ff2b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
26 changes: 20 additions & 6 deletions custom_components/open_meteo_solar_forecast/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
from typing import Any

import voluptuous as vol
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
OptionsFlow,
)
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv

from .const import (
CONF_AZIMUTH,
CONF_BASE_URL,
CONF_DAMPING_EVENING,
CONF_DAMPING_MORNING,
CONF_DECLINATION,
CONF_EFFICIENCY_FACTOR,
CONF_MODULES_POWER,
CONF_INVERTER_POWER,
CONF_MODULES_POWER,
DOMAIN,
)

Expand Down Expand Up @@ -58,6 +56,8 @@ async def async_step_user(
CONF_API_KEY: user_input[CONF_API_KEY],
CONF_AZIMUTH: user_input[CONF_AZIMUTH],
CONF_BASE_URL: user_input[CONF_BASE_URL],
CONF_DAMPING_MORNING: user_input[CONF_DAMPING_MORNING],
CONF_DAMPING_EVENING: user_input[CONF_DAMPING_EVENING],
CONF_DECLINATION: user_input[CONF_DECLINATION],
CONF_MODULES_POWER: user_input[CONF_MODULES_POWER],
CONF_INVERTER_POWER: user_input[CONF_INVERTER_POWER],
Expand Down Expand Up @@ -94,6 +94,8 @@ async def async_step_user(
vol.Required(CONF_INVERTER_POWER, default=0): vol.All(
vol.Coerce(int), vol.Range(min=0)
),
vol.Optional(CONF_DAMPING_MORNING, default=0.0): vol.Coerce(float),
vol.Optional(CONF_DAMPING_EVENING, default=0.0): vol.Coerce(float),
vol.Optional(CONF_EFFICIENCY_FACTOR, default=1.0): vol.All(
vol.Coerce(float), vol.Range(min=0)
),
Expand Down Expand Up @@ -147,6 +149,18 @@ async def async_step_init(
CONF_MODULES_POWER,
default=self.config_entry.options[CONF_MODULES_POWER],
): vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(
CONF_DAMPING_MORNING,
default=self.config_entry.options.get(
CONF_DAMPING_MORNING, 0.0
),
): vol.Coerce(float),
vol.Optional(
CONF_DAMPING_EVENING,
default=self.config_entry.options.get(
CONF_DAMPING_EVENING, 0.0
),
): vol.Coerce(float),
vol.Required(
CONF_INVERTER_POWER,
default=self.config_entry.options.get(CONF_INVERTER_POWER, 0),
Expand Down
2 changes: 2 additions & 0 deletions custom_components/open_meteo_solar_forecast/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
CONF_DECLINATION = "declination"
CONF_AZIMUTH = "azimuth"
CONF_MODULES_POWER = "modules_power"
CONF_DAMPING_MORNING = "damping_morning"
CONF_DAMPING_EVENING = "damping_evening"
CONF_INVERTER_POWER = "inverter_power"
CONF_EFFICIENCY_FACTOR = "efficiency_factor"

Expand Down
8 changes: 6 additions & 2 deletions custom_components/open_meteo_solar_forecast/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

from datetime import timedelta

from open_meteo_solar_forecast import Estimate, OpenMeteoSolarForecast

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from open_meteo_solar_forecast import Estimate, OpenMeteoSolarForecast

from .const import (
CONF_AZIMUTH,
CONF_BASE_URL,
CONF_DAMPING_EVENING,
CONF_DAMPING_MORNING,
CONF_DECLINATION,
CONF_EFFICIENCY_FACTOR,
CONF_INVERTER_POWER,
Expand Down Expand Up @@ -52,6 +54,8 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
dc_kwp=(entry.options[CONF_MODULES_POWER] / 1000),
declination=entry.options[CONF_DECLINATION],
efficiency_factor=entry.options[CONF_EFFICIENCY_FACTOR],
damping_morning=entry.options.get(CONF_DAMPING_MORNING, 0.0),
damping_evening=entry.options.get(CONF_DAMPING_EVENING, 0.0),
)

update_interval = timedelta(minutes=30)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/open_meteo_solar_forecast/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/rany2/ha-open-meteo-solar-forecast/issues",
"requirements": ["open_meteo_solar_forecast==0.1.17"],
"version": "0.1.15"
"requirements": ["open_meteo_solar_forecast==0.1.18"],
"version": "0.1.16"
}
4 changes: 4 additions & 0 deletions custom_components/open_meteo_solar_forecast/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]",
"azimuth": "Azimuth (360 degrees, 0 = North, 90 = East, 180 = South, 270 = West)",
"damping_morning": "Damping factor: adjusts the results in the morning",
"damping_evening": "Damping factor: adjusts the results in the evening",
"declination": "Declination (0 = Horizontal, 90 = Vertical)",
"latitude": "[%key:common::config_flow::data::latitude%]",
"longitude": "[%key:common::config_flow::data::longitude%]",
Expand All @@ -27,6 +29,8 @@
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]",
"azimuth": "[%key:component::solar_forecast::config::step::user::data::azimuth%]",
"damping_morning": "[%key:component::solar_forecast::config::step::user::data::damping_morning%]",
"damping_evening": "[%key:component::solar_forecast::config::step::user::data::damping_evening%]",
"declination": "[%key:component::solar_forecast::config::step::user::data::declination%]",
"efficiency_factor": "[%key:component::solar_forecast::config::step::user::data::efficiency_factor%]",
"modules_power": "[%key:component::solar_forecast::config::step::user::data::modules_power%]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"data": {
"api_key": "API key",
"azimuth": "Azimuth (360 degrees, 0 = North, 90 = East, 180 = South, 270 = West)",
"damping_morning": "Damping factor: adjusts the results in the morning",
"damping_evening": "Damping factor: adjusts the results in the evening",
"declination": "Declination (0 = Horizontal, 90 = Vertical)",
"latitude": "Latitude",
"longitude": "Longitude",
Expand Down Expand Up @@ -87,6 +89,8 @@
"data": {
"api_key": "API key",
"azimuth": "Azimuth (360 degrees, 0 = North, 90 = East, 180 = South, 270 = West)",
"damping_morning": "Damping factor: adjusts the results in the morning",
"damping_evening": "Damping factor: adjusts the results in the evening",
"declination": "Declination (0 = Horizontal, 90 = Vertical)",
"inverter_size": "Inverter size (Watt)",
"efficiency_factor": "DC efficiency factor (0.0-1.0, 0.0 = 100% loss, 1.0 = no loss)",
Expand Down

0 comments on commit ee2ff2b

Please sign in to comment.