From a16d2008fa658ae18ef0bd97610e8b82accabf43 Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Sun, 12 Jan 2025 21:32:48 +0000 Subject: [PATCH] config_entry assignation is deprecated Otherwise the following warning is raised: Logger: homeassistant.helpers.frame Source: helpers/frame.py:324 First occurred: January 11, 2025 at 23:29:37 (4 occurrences) Last logged: 00:16:34 Detected that custom integration 'pun_sensor' sets option flow config_entry explicitly, which is deprecated at custom_components/pun_sensor/config_flow.py, line 33: self.config_entry = entry. This will stop working in Home Assistant 2025.12, please create a bug report at https://github.com/virtualdj/pun_sensor/issues Deprecation happened in https://github.com/home-assistant/core/commit/6d561a9796a91d4e28976e6ebd177d61e60bd5c9 --- custom_components/pun_sensor/config_flow.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/custom_components/pun_sensor/config_flow.py b/custom_components/pun_sensor/config_flow.py index e337072..172ab18 100644 --- a/custom_components/pun_sensor/config_flow.py +++ b/custom_components/pun_sensor/config_flow.py @@ -28,9 +28,13 @@ class PUNOptionsFlow(config_entries.OptionsFlow): """Opzioni per prezzi PUN (= riconfigurazione successiva).""" - def __init__(self, entry: config_entries.ConfigEntry) -> None: + def __init__(self, *args, **kwargs) -> None: """Inizializzazione opzioni.""" - self.config_entry = entry + super().__init__(*args, **kwargs) + if AwesomeVersion(HA_VERSION) < AwesomeVersion("2024.12.0b0"): + entry: config_entries.ConfigEntry + entry, *args = args + self.config_entry = entry async def async_step_init(self, user_input=None) -> FlowResult: """Gestisce le opzioni di configurazione.""" @@ -79,7 +83,11 @@ def async_get_options_flow( config_entry: config_entries.ConfigEntry, ) -> PUNOptionsFlow: """Ottiene le opzioni per questa configurazione.""" - return PUNOptionsFlow(config_entry) + if AwesomeVersion(HA_VERSION) < AwesomeVersion("2024.12.0b0"): + options_flow = PUNOptionsFlow(config_entry) + else: + options_flow = PUNOptionsFlow() + return options_flow async def async_step_user(self, user_input=None): """Gestione prima configurazione da Home Assistant."""