From 5a8b6de2196a18be3ee4e3266c80dbb60c3ea0a7 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 1 Jan 2025 16:34:41 -0800 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20setting=20config=5Fentry=20directly?= =?UTF-8?q?=20in=20=E2=89=A52024.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FAILED tests/components/adaptive_lighting/test_config_flow.py::test_incorrect_options - RuntimeError: Detected that integration 'adaptive_lighting' sets option flow config_entry explicitly, which is deprecated at homeassistant/components/adaptive_lighting/config_flow.py, line 86: self.config_entry = config_entry. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+adaptive_lighting%22 --- custom_components/adaptive_lighting/config_flow.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/adaptive_lighting/config_flow.py b/custom_components/adaptive_lighting/config_flow.py index f0098937..1007cae5 100644 --- a/custom_components/adaptive_lighting/config_flow.py +++ b/custom_components/adaptive_lighting/config_flow.py @@ -5,7 +5,7 @@ import homeassistant.helpers.config_validation as cv import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import CONF_NAME +from homeassistant.const import CONF_NAME, MAJOR_VERSION, MINOR_VERSION from homeassistant.core import callback from .const import ( # pylint: disable=unused-import @@ -58,6 +58,9 @@ async def async_step_import(self, user_input=None): @callback def async_get_options_flow(config_entry): """Get the options flow for this handler.""" + if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 12): + # https://github.com/home-assistant/core/pull/129651 + return OptionsFlowHandler() return OptionsFlowHandler(config_entry) From 3d1804e921ed1ef5e24f4627c75bb12c6c0597d0 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 1 Jan 2025 16:40:01 -0800 Subject: [PATCH 2/2] compatiblity --- custom_components/adaptive_lighting/config_flow.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/adaptive_lighting/config_flow.py b/custom_components/adaptive_lighting/config_flow.py index 1007cae5..3922d000 100644 --- a/custom_components/adaptive_lighting/config_flow.py +++ b/custom_components/adaptive_lighting/config_flow.py @@ -84,9 +84,13 @@ def validate_options(user_input, errors): class OptionsFlowHandler(config_entries.OptionsFlow): """Handle a option flow for Adaptive Lighting.""" - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: + def __init__(self, *args, **kwargs) -> None: """Initialize options flow.""" - self.config_entry = config_entry + if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 12): + super().__init__(*args, **kwargs) + # https://github.com/home-assistant/core/pull/129651 + else: + self.config_entry = args[0] async def async_step_init(self, user_input=None): """Handle options flow."""