From 7dda89c5cb88ee15ffc32292be9e9422f03110ae Mon Sep 17 00:00:00 2001 From: thekiwismarthome <134335563+thekiwismarthome@users.noreply.github.com> Date: Fri, 13 Feb 2026 14:54:38 +1300 Subject: [PATCH] Create images.py --- .../shopping_list_manager/utils/images.py | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 custom_components/shopping_list_manager/utils/images.py diff --git a/custom_components/shopping_list_manager/utils/images.py b/custom_components/shopping_list_manager/utils/images.py new file mode 100644 index 0000000..2cf7bc7 --- /dev/null +++ b/custom_components/shopping_list_manager/utils/images.py @@ -0,0 +1,92 @@ +"""Config flow for Shopping List Manager.""" +import voluptuous as vol +from homeassistant import config_entries +from homeassistant.core import callback + +from .const import DOMAIN + + +class ShoppingListManagerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): + """Handle a config flow for Shopping List Manager.""" + + VERSION = 1 + + def __init__(self): + """Initialize config flow.""" + self._data = {} + + async def async_step_user(self, user_input=None): + """Handle the initial step.""" + # Only allow one instance + if self._async_current_entries(): + return self.async_abort(reason="single_instance_allowed") + + if user_input is not None: + # Store initial list name + self._data["initial_list_name"] = user_input.get("list_name", "Shopping List") + return await self.async_step_features() + + # Show setup form + return self.async_show_form( + step_id="user", + data_schema=vol.Schema({ + vol.Optional("list_name", default="Shopping List"): str, + }), + description_placeholders={ + "version": "2.0.0", + } + ) + + async def async_step_features(self, user_input=None): + """Configure optional features.""" + if user_input is not None: + self._data.update(user_input) + return self.async_create_entry( + title="Shopping List Manager", + data=self._data + ) + + return self.async_show_form( + step_id="features", + data_schema=vol.Schema({ + vol.Optional("enable_price_tracking", default=True): bool, + vol.Optional("enable_image_search", default=True): bool, + vol.Optional("metric_units_only", default=True): bool, + }), + description_placeholders={ + "features": "Configure optional features for your shopping lists" + } + ) + + @staticmethod + @callback + def async_get_options_flow(config_entry): + """Get the options flow for this handler.""" + return OptionsFlowHandler(config_entry) + + +class OptionsFlowHandler(config_entries.OptionsFlow): + """Handle options flow for Shopping List Manager.""" + + def __init__(self, config_entry): + """Initialize options flow.""" + self.config_entry = config_entry + + async def async_step_init(self, user_input=None): + """Manage the options.""" + if user_input is not None: + return self.async_create_entry(title="", data=user_input) + + return self.async_show_form( + step_id="init", + data_schema=vol.Schema({ + vol.Optional( + "enable_price_tracking", + default=self.config_entry.data.get("enable_price_tracking", True) + ): bool, + vol.Optional( + "enable_image_search", + default=self.config_entry.data.get("enable_image_search", True) + ): bool, + }) + )