Update config_flow.py

This commit is contained in:
thekiwismarthome
2026-02-13 21:18:13 +13:00
committed by GitHub
parent b2da5e62bd
commit d1573846cd
@@ -22,14 +22,22 @@ class ShoppingListManagerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="single_instance_allowed") return self.async_abort(reason="single_instance_allowed")
if user_input is not None: if user_input is not None:
# Store initial list name # Store country and initial list name
self._data["country"] = user_input.get("country", "NZ")
self._data["initial_list_name"] = user_input.get("list_name", "Shopping List") self._data["initial_list_name"] = user_input.get("list_name", "Shopping List")
return await self.async_step_features() return await self.async_step_features()
# Show setup form # Show setup form with country selection
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
data_schema=vol.Schema({ data_schema=vol.Schema({
vol.Required("country", default="NZ"): vol.In({
"NZ": "New Zealand",
"AU": "Australia",
"US": "United States",
"GB": "United Kingdom",
"CA": "Canada",
}),
vol.Optional("list_name", default="Shopping List"): str, vol.Optional("list_name", default="Shopping List"): str,
}), }),
description_placeholders={ description_placeholders={
@@ -80,6 +88,16 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
return self.async_show_form( return self.async_show_form(
step_id="init", step_id="init",
data_schema=vol.Schema({ data_schema=vol.Schema({
vol.Required(
"country",
default=self.config_entry.data.get("country", "NZ")
): vol.In({
"NZ": "New Zealand",
"AU": "Australia",
"US": "United States",
"GB": "United Kingdom",
"CA": "Canada",
}),
vol.Optional( vol.Optional(
"enable_price_tracking", "enable_price_tracking",
default=self.config_entry.data.get("enable_price_tracking", True) default=self.config_entry.data.get("enable_price_tracking", True)