Skip to content

Commit 72eb848

Browse files
authored
Fix setting config_entry directly in ≥2024.12 (#1155)
* Fix setting config_entry directly in ≥2024.12 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 * compatiblity
1 parent 32482c4 commit 72eb848

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

custom_components/adaptive_lighting/config_flow.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import homeassistant.helpers.config_validation as cv
66
import voluptuous as vol
77
from homeassistant import config_entries
8-
from homeassistant.const import CONF_NAME
8+
from homeassistant.const import CONF_NAME, MAJOR_VERSION, MINOR_VERSION
99
from homeassistant.core import callback
1010

1111
from .const import ( # pylint: disable=unused-import
@@ -58,6 +58,9 @@ async def async_step_import(self, user_input=None):
5858
@callback
5959
def async_get_options_flow(config_entry):
6060
"""Get the options flow for this handler."""
61+
if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 12):
62+
# https://github.com/home-assistant/core/pull/129651
63+
return OptionsFlowHandler()
6164
return OptionsFlowHandler(config_entry)
6265

6366

@@ -81,9 +84,13 @@ def validate_options(user_input, errors):
8184
class OptionsFlowHandler(config_entries.OptionsFlow):
8285
"""Handle a option flow for Adaptive Lighting."""
8386

84-
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
87+
def __init__(self, *args, **kwargs) -> None:
8588
"""Initialize options flow."""
86-
self.config_entry = config_entry
89+
if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 12):
90+
super().__init__(*args, **kwargs)
91+
# https://github.com/home-assistant/core/pull/129651
92+
else:
93+
self.config_entry = args[0]
8794

8895
async def async_step_init(self, user_input=None):
8996
"""Handle options flow."""

0 commit comments

Comments
 (0)