Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting config_entry directly in ≥2024.12 #1155

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions custom_components/adaptive_lighting/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand All @@ -81,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."""
Expand Down
Loading