Skip to content

Commit

Permalink
config_entry assignation is deprecated
Browse files Browse the repository at this point in the history
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 home-assistant/core@6d561a9
  • Loading branch information
Daemo00 committed Jan 17, 2025
1 parent 433d107 commit a16d200
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions custom_components/pun_sensor/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit a16d200

Please sign in to comment.