diff --git a/custom_components/open_meteo_solar_forecast/config_flow.py b/custom_components/open_meteo_solar_forecast/config_flow.py index 5cf15e6..bda1f70 100644 --- a/custom_components/open_meteo_solar_forecast/config_flow.py +++ b/custom_components/open_meteo_solar_forecast/config_flow.py @@ -21,6 +21,7 @@ CONF_DECLINATION, CONF_EFFICIENCY_FACTOR, CONF_MODULES_POWER, + CONF_INVERTER_POWER, DOMAIN, ) @@ -55,6 +56,7 @@ async def async_step_user( CONF_BASE_URL: user_input[CONF_BASE_URL], CONF_DECLINATION: user_input[CONF_DECLINATION], CONF_MODULES_POWER: user_input[CONF_MODULES_POWER], + CONF_INVERTER_POWER: user_input[CONF_INVERTER_POWER], CONF_EFFICIENCY_FACTOR: user_input[CONF_EFFICIENCY_FACTOR], }, ) @@ -85,6 +87,9 @@ async def async_step_user( vol.Required(CONF_MODULES_POWER): vol.All( vol.Coerce(int), vol.Range(min=1) ), + vol.Required(CONF_INVERTER_POWER, default=0): vol.All( + vol.Coerce(int), vol.Range(min=0) + ), vol.Optional(CONF_EFFICIENCY_FACTOR, default=1.0): vol.All( vol.Coerce(float), vol.Range(min=0) ), @@ -138,6 +143,10 @@ 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.Required( + CONF_INVERTER_POWER, + default=self.config_entry.options.get(CONF_INVERTER_POWER, 0), + ): vol.All(vol.Coerce(int), vol.Range(min=0)), vol.Optional( CONF_EFFICIENCY_FACTOR, default=self.config_entry.options.get( diff --git a/custom_components/open_meteo_solar_forecast/const.py b/custom_components/open_meteo_solar_forecast/const.py index 4f8f797..9b24073 100644 --- a/custom_components/open_meteo_solar_forecast/const.py +++ b/custom_components/open_meteo_solar_forecast/const.py @@ -11,4 +11,5 @@ CONF_DECLINATION = "declination" CONF_AZIMUTH = "azimuth" CONF_MODULES_POWER = "modules_power" +CONF_INVERTER_POWER = "inverter_power" CONF_EFFICIENCY_FACTOR = "efficiency_factor" \ No newline at end of file diff --git a/custom_components/open_meteo_solar_forecast/coordinator.py b/custom_components/open_meteo_solar_forecast/coordinator.py index 99397ec..1f8f0dc 100644 --- a/custom_components/open_meteo_solar_forecast/coordinator.py +++ b/custom_components/open_meteo_solar_forecast/coordinator.py @@ -17,6 +17,7 @@ CONF_BASE_URL, CONF_DECLINATION, CONF_EFFICIENCY_FACTOR, + CONF_INVERTER_POWER, CONF_MODULES_POWER, DOMAIN, LOGGER, @@ -36,6 +37,10 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None: # this if statement is here to catch that. api_key = entry.options.get(CONF_API_KEY) or None + # Handle new options that were added after the initial release + ac_kwp = entry.options.get(CONF_INVERTER_POWER, 0) + ac_kwp = ac_kwp / 1000 if ac_kwp else None + self.forecast = OpenMeteoSolarForecast( api_key=api_key, session=async_get_clientsession(hass), @@ -43,9 +48,10 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None: longitude=entry.data[CONF_LONGITUDE], azimuth=entry.options[CONF_AZIMUTH] - 180, base_url=entry.options[CONF_BASE_URL], + ac_kwp=ac_kwp, + dc_kwp=(entry.options[CONF_MODULES_POWER] / 1000), declination=entry.options[CONF_DECLINATION], efficiency_factor=entry.options[CONF_EFFICIENCY_FACTOR], - kwp=(entry.options[CONF_MODULES_POWER] / 1000), ) update_interval = timedelta(minutes=30) diff --git a/custom_components/open_meteo_solar_forecast/manifest.json b/custom_components/open_meteo_solar_forecast/manifest.json index b53d17f..6cffe0d 100644 --- a/custom_components/open_meteo_solar_forecast/manifest.json +++ b/custom_components/open_meteo_solar_forecast/manifest.json @@ -6,7 +6,7 @@ "documentation": "https://github.com/rany2/ha-open-meteo-solar-forecast", "integration_type": "service", "iot_class": "cloud_polling", - "requirements": ["open_meteo_solar_forecast==0.1.13"], + "requirements": ["open_meteo_solar_forecast==0.1.14"], "version": "0.1.9", "issue_tracker": "https://github.com/rany2/ha-open-meteo-solar-forecast/issues", "documentation": "https://github.com/rany2/ha-open-meteo-solar-forecast" diff --git a/custom_components/open_meteo_solar_forecast/strings.json b/custom_components/open_meteo_solar_forecast/strings.json index 121509b..1b8aa25 100644 --- a/custom_components/open_meteo_solar_forecast/strings.json +++ b/custom_components/open_meteo_solar_forecast/strings.json @@ -11,6 +11,7 @@ "longitude": "[%key:common::config_flow::data::longitude%]", "efficiency_factor": "DC efficiency factor (0.0-1.0, 0.0 = 100% loss, 1.0 = no loss)", "modules_power": "Total Watt peak power of your solar modules", + "inverter_power": "The capacity of your inverter in Watt", "name": "[%key:common::config_flow::data::name%]" } } @@ -28,7 +29,8 @@ "azimuth": "[%key:component::solar_forecast::config::step::user::data::azimuth%]", "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%]" + "modules_power": "[%key:component::solar_forecast::config::step::user::data::modules_power%]", + "inverter_power": "[%key:component::solar_forecast::config::step::user::data::inverter_power%]" } } } diff --git a/custom_components/open_meteo_solar_forecast/translations/en.json b/custom_components/open_meteo_solar_forecast/translations/en.json index 7e12eba..1341909 100644 --- a/custom_components/open_meteo_solar_forecast/translations/en.json +++ b/custom_components/open_meteo_solar_forecast/translations/en.json @@ -10,6 +10,7 @@ "longitude": "Longitude", "efficiency_factor": "DC efficiency factor (0.0-1.0, 0.0 = 100% loss, 1.0 = no loss)", "modules_power": "Total Watt peak power of your solar modules", + "inverter_power": "The capacity of your inverter in Watt", "name": "Name" }, "description": "Fill in the data of your solar panels. Please refer to the documentation if a field is unclear." @@ -89,7 +90,8 @@ "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)", - "modules_power": "Total Watt peak power of your solar modules" + "modules_power": "Total Watt peak power of your solar modules", + "inverter_power": "The capacity of your inverter in Watt" }, "description": "These values allow tweaking the Forecast.Solar result. Please refer to the documentation if a field is unclear." }