Skip to content

Commit a79c42c

Browse files
authored
Merge pull request #67 from dudanov/fix-options-flow-handler-init
fix: OptionsFlowHandler initialization
2 parents 1a6250e + 55b7c1e commit a79c42c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

custom_components/qingping_cgs1/config_flow.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,33 +192,29 @@ def _handle_message(msg):
192192
@callback
193193
def async_get_options_flow(config_entry):
194194
"""Get the options flow for this handler."""
195-
return OptionsFlowHandler(config_entry)
195+
return OptionsFlowHandler()
196196

197197
class OptionsFlowHandler(config_entries.OptionsFlow):
198198
"""Handle options flow for Qingping CGS1."""
199199

200-
def __init__(self, entry: config_entries.ConfigEntry) -> None:
201-
"""Initialize options flow."""
202-
super().__init__(entry) # Use parent class initialization instead
203-
204200
async def async_step_init(
205201
self, user_input: dict[str, Any] | None = None
206202
) -> FlowResult:
207203
"""Manage the options."""
208204
if user_input is not None:
209205
# Update the config entry
210206
new_data = {
211-
**self.entry.data, # Use self.entry instead of self.config_entry
207+
**self.config_entry.data,
212208
CONF_MODEL: user_input[CONF_MODEL]
213209
}
214210

215211
self.hass.config_entries.async_update_entry(
216-
self.entry, # Use self.entry instead of self.config_entry
212+
self.config_entry,
217213
data=new_data,
218214
)
219215

220216
# Reload the integration to apply changes
221-
await self.hass.config_entries.async_reload(self.entry.entry_id)
217+
await self.hass.config_entries.async_reload(self._config_entry_id)
222218

223219
return self.async_create_entry(title="", data=user_input)
224220

@@ -227,7 +223,7 @@ async def async_step_init(
227223
data_schema=vol.Schema({
228224
vol.Required(
229225
CONF_MODEL,
230-
default=self.entry.data.get(CONF_MODEL, DEFAULT_MODEL) # Use self.entry
226+
default=self.config_entry.data.get(CONF_MODEL, DEFAULT_MODEL)
231227
): vol.In(QP_MODELS),
232228
}),
233229
)

0 commit comments

Comments
 (0)