diff --git a/homeassistant/components/forecast_solar/__init__.py b/homeassistant/components/forecast_solar/__init__.py index 760ad04af98..d4e8e3af969 100644 --- a/homeassistant/components/forecast_solar/__init__.py +++ b/homeassistant/components/forecast_solar/__init__.py @@ -16,6 +16,7 @@ from .const import ( CONF_AZIMUTH, CONF_DAMPING, CONF_DECLINATION, + CONF_INVERTER_SIZE, CONF_MODULES_POWER, DOMAIN, ) @@ -29,6 +30,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # this if statement is here to catch that. api_key = entry.options.get(CONF_API_KEY) or None + if ( + inverter_size := entry.options.get(CONF_INVERTER_SIZE) + ) is not None and inverter_size > 0: + inverter_size = inverter_size / 1000 + session = async_get_clientsession(hass) forecast = ForecastSolar( api_key=api_key, @@ -39,6 +45,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: azimuth=(entry.options[CONF_AZIMUTH] - 180), kwp=(entry.options[CONF_MODULES_POWER] / 1000), damping=entry.options.get(CONF_DAMPING, 0), + inverter=inverter_size, ) # Free account have a resolution of 1 hour, using that as the default diff --git a/homeassistant/components/forecast_solar/config_flow.py b/homeassistant/components/forecast_solar/config_flow.py index e7f41777062..86de17ef285 100644 --- a/homeassistant/components/forecast_solar/config_flow.py +++ b/homeassistant/components/forecast_solar/config_flow.py @@ -15,6 +15,7 @@ from .const import ( CONF_AZIMUTH, CONF_DAMPING, CONF_DECLINATION, + CONF_INVERTER_SIZE, CONF_MODULES_POWER, DOMAIN, ) @@ -118,6 +119,14 @@ class ForecastSolarOptionFlowHandler(OptionsFlow): CONF_DAMPING, default=self.config_entry.options.get(CONF_DAMPING, 0.0), ): vol.Coerce(float), + vol.Optional( + CONF_INVERTER_SIZE, + description={ + "suggested_value": self.config_entry.options.get( + CONF_INVERTER_SIZE + ) + }, + ): vol.Coerce(int), } ), ) diff --git a/homeassistant/components/forecast_solar/const.py b/homeassistant/components/forecast_solar/const.py index 63d5bd10084..d9742cf5dfc 100644 --- a/homeassistant/components/forecast_solar/const.py +++ b/homeassistant/components/forecast_solar/const.py @@ -14,6 +14,7 @@ CONF_DECLINATION = "declination" CONF_AZIMUTH = "azimuth" CONF_MODULES_POWER = "modules power" CONF_DAMPING = "damping" +CONF_INVERTER_SIZE = "inverter_size" SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = ( ForecastSolarSensorEntityDescription( diff --git a/homeassistant/components/forecast_solar/manifest.json b/homeassistant/components/forecast_solar/manifest.json index dc4b88d160c..472f5cac213 100644 --- a/homeassistant/components/forecast_solar/manifest.json +++ b/homeassistant/components/forecast_solar/manifest.json @@ -3,7 +3,7 @@ "name": "Forecast.Solar", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/forecast_solar", - "requirements": ["forecast_solar==2.1.0"], + "requirements": ["forecast_solar==2.2.0"], "codeowners": ["@klaasnicolaas", "@frenck"], "quality_scale": "platinum", "iot_class": "cloud_polling" diff --git a/homeassistant/components/forecast_solar/strings.json b/homeassistant/components/forecast_solar/strings.json index e1ae451a04f..b10e927eb8b 100644 --- a/homeassistant/components/forecast_solar/strings.json +++ b/homeassistant/components/forecast_solar/strings.json @@ -22,6 +22,7 @@ "api_key": "Forecast.Solar API Key (optional)", "azimuth": "Azimuth (360 degrees, 0 = North, 90 = East, 180 = South, 270 = West)", "damping": "Damping factor: adjusts the results in the morning and evening", + "inverter_size": "Inverter size (Watt)", "declination": "Declination (0 = Horizontal, 90 = Vertical)", "modules power": "Total Watt peak power of your solar modules" } diff --git a/homeassistant/components/forecast_solar/translations/en.json b/homeassistant/components/forecast_solar/translations/en.json index f9eef2b5c0a..db9bead2e8c 100644 --- a/homeassistant/components/forecast_solar/translations/en.json +++ b/homeassistant/components/forecast_solar/translations/en.json @@ -21,6 +21,7 @@ "api_key": "Forecast.Solar API Key (optional)", "azimuth": "Azimuth (360 degrees, 0 = North, 90 = East, 180 = South, 270 = West)", "damping": "Damping factor: adjusts the results in the morning and evening", + "inverter_size": "Inverter size (Watt)", "declination": "Declination (0 = Horizontal, 90 = Vertical)", "modules power": "Total Watt peak power of your solar modules" }, diff --git a/requirements_all.txt b/requirements_all.txt index 518345320fd..4047f66c811 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -658,7 +658,7 @@ fnvhash==0.1.0 foobot_async==1.0.0 # homeassistant.components.forecast_solar -forecast_solar==2.1.0 +forecast_solar==2.2.0 # homeassistant.components.fortios fortiosapi==1.0.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 678a071db62..f1c79379eb8 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -453,7 +453,7 @@ fnvhash==0.1.0 foobot_async==1.0.0 # homeassistant.components.forecast_solar -forecast_solar==2.1.0 +forecast_solar==2.2.0 # homeassistant.components.freebox freebox-api==0.0.10 diff --git a/tests/components/forecast_solar/conftest.py b/tests/components/forecast_solar/conftest.py index 408c5423861..0d9f76b367e 100644 --- a/tests/components/forecast_solar/conftest.py +++ b/tests/components/forecast_solar/conftest.py @@ -11,6 +11,7 @@ from homeassistant.components.forecast_solar.const import ( CONF_AZIMUTH, CONF_DAMPING, CONF_DECLINATION, + CONF_INVERTER_SIZE, CONF_MODULES_POWER, DOMAIN, ) @@ -38,6 +39,7 @@ def mock_config_entry() -> MockConfigEntry: CONF_AZIMUTH: 190, CONF_MODULES_POWER: 5100, CONF_DAMPING: 0.5, + CONF_INVERTER_SIZE: 2000, }, ) diff --git a/tests/components/forecast_solar/test_config_flow.py b/tests/components/forecast_solar/test_config_flow.py index d175be986ca..f0611d1678d 100644 --- a/tests/components/forecast_solar/test_config_flow.py +++ b/tests/components/forecast_solar/test_config_flow.py @@ -5,6 +5,7 @@ from homeassistant.components.forecast_solar.const import ( CONF_AZIMUTH, CONF_DAMPING, CONF_DECLINATION, + CONF_INVERTER_SIZE, CONF_MODULES_POWER, DOMAIN, ) @@ -81,6 +82,7 @@ async def test_options_flow( CONF_AZIMUTH: 22, CONF_MODULES_POWER: 2122, CONF_DAMPING: 0.25, + CONF_INVERTER_SIZE: 2000, }, ) @@ -91,4 +93,5 @@ async def test_options_flow( CONF_AZIMUTH: 22, CONF_MODULES_POWER: 2122, CONF_DAMPING: 0.25, + CONF_INVERTER_SIZE: 2000, }