From ff3e85d38412dc00e43f3b489edb7c17709bb76a Mon Sep 17 00:00:00 2001 From: thekiwismarthome <134335563+thekiwismarthome@users.noreply.github.com> Date: Fri, 6 Feb 2026 08:36:47 +1300 Subject: [PATCH] Add files via upload --- .../shopping_list_manager/__init__.py | 51 ++++++------------- .../frontend/shopping_list_card.js | 2 +- .../shopping_list_manager/manifest.json | 4 +- 3 files changed, 19 insertions(+), 38 deletions(-) diff --git a/custom_components/shopping_list_manager/__init__.py b/custom_components/shopping_list_manager/__init__.py index edf468c..5617f08 100644 --- a/custom_components/shopping_list_manager/__init__.py +++ b/custom_components/shopping_list_manager/__init__.py @@ -3,35 +3,24 @@ Shopping List Manager - Home Assistant Custom Integration Clean-slate architecture with enforced invariants """ import logging -from pathlib import Path from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from homeassistant.components import websocket_api +from homeassistant.components import websocket_api as ha_websocket from .const import DOMAIN from .manager import ShoppingListManager +# Import websocket handler functions directly +from .websocket_api import ( + websocket_add_product, + websocket_set_qty, + websocket_get_products, + websocket_get_active, + websocket_delete_product, +) _LOGGER = logging.getLogger(__name__) -async def async_setup(hass: HomeAssistant, config: dict) -> bool: - """Set up the Shopping List Manager component.""" - # Register frontend path for the card (updated for HA 2023+) - frontend_path = Path(__file__).parent / "frontend" - hass.http.async_register_static_paths( - [ - { - "url_path": f"/hacsfiles/{DOMAIN}", - "path": str(frontend_path), - "cache_headers": False, - } - ] - ) - _LOGGER.info(f"Registered frontend path: /hacsfiles/{DOMAIN}") - - return True - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Shopping List Manager from a config entry.""" # Initialize the manager @@ -42,20 +31,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN]["manager"] = manager - # Register WebSocket commands - from .websocket_api import ( - websocket_add_product, - websocket_set_qty, - websocket_get_products, - websocket_get_active, - websocket_delete_product, - ) - - websocket_api.async_register_command(hass, websocket_add_product) - websocket_api.async_register_command(hass, websocket_set_qty) - websocket_api.async_register_command(hass, websocket_get_products) - websocket_api.async_register_command(hass, websocket_get_active) - websocket_api.async_register_command(hass, websocket_delete_product) + # Register WebSocket commands using Home Assistant's websocket_api + ha_websocket.async_register_command(hass, websocket_add_product) + ha_websocket.async_register_command(hass, websocket_set_qty) + ha_websocket.async_register_command(hass, websocket_get_products) + ha_websocket.async_register_command(hass, websocket_get_active) + ha_websocket.async_register_command(hass, websocket_delete_product) _LOGGER.info("Shopping List Manager setup complete - registered 5 WebSocket commands") @@ -65,4 +46,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload Shopping List Manager.""" hass.data[DOMAIN].pop("manager", None) - return True + return True \ No newline at end of file diff --git a/custom_components/shopping_list_manager/frontend/shopping_list_card.js b/custom_components/shopping_list_manager/frontend/shopping_list_card.js index b88d4a8..4731099 100644 --- a/custom_components/shopping_list_manager/frontend/shopping_list_card.js +++ b/custom_components/shopping_list_manager/frontend/shopping_list_card.js @@ -2199,4 +2199,4 @@ window.customCards.push({ name: 'Shopping List', description: 'A shopping list card with search, categories, and product images.', preview: false -}); +}); \ No newline at end of file diff --git a/custom_components/shopping_list_manager/manifest.json b/custom_components/shopping_list_manager/manifest.json index ca5446f..460556f 100644 --- a/custom_components/shopping_list_manager/manifest.json +++ b/custom_components/shopping_list_manager/manifest.json @@ -1,7 +1,7 @@ { "domain": "shopping_list_manager", "name": "Shopping List Manager", - "version": "1.1.0", + "version": "1.0.0", "documentation": "https://github.com/thekiwismarthome/shopping-list-manager", "issue_tracker": "https://github.com/thekiwismarthome/shopping-list-manager/issues", "requirements": [], @@ -9,4 +9,4 @@ "codeowners": ["@thekiwismarthome"], "config_flow": true, "iot_class": "local_polling" -} +} \ No newline at end of file