From ab5bd34c0764abcc83e4e5d9cb368d29999a0747 Mon Sep 17 00:00:00 2001 From: thekiwismarthome <134335563+thekiwismarthome@users.noreply.github.com> Date: Fri, 13 Feb 2026 20:19:04 +1300 Subject: [PATCH] Update __init__.py --- custom_components/shopping_list_manager/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/custom_components/shopping_list_manager/__init__.py b/custom_components/shopping_list_manager/__init__.py index ea2a1b7..e321314 100644 --- a/custom_components/shopping_list_manager/__init__.py +++ b/custom_components/shopping_list_manager/__init__.py @@ -8,6 +8,7 @@ from homeassistant.helpers.typing import ConfigType from .const import DOMAIN from .storage import ShoppingListStorage +from .utils.images import ImageHandler _LOGGER = logging.getLogger(__name__) @@ -22,17 +23,27 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: return True +# In async_setup_entry function, after storage initialization: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Shopping List Manager from a config entry.""" _LOGGER.info("Setting up Shopping List Manager") # Get component path for loading data files component_path = os.path.dirname(__file__) + config_path = hass.config.path() # Initialize storage storage = ShoppingListStorage(hass, component_path) await storage.async_load() + # Initialize image handler + image_handler = ImageHandler(hass, config_path) + + # Store instances in hass.data + hass.data.setdefault(DOMAIN, {}) + hass.data[DOMAIN][DATA_STORAGE] = storage + hass.data[DOMAIN]["image_handler"] = image_handler # NEW + # Store storage instance in hass.data hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][DATA_STORAGE] = storage