From c9c1d16f08e3c6de0d87c76b84cd3dd95957a9a7 Mon Sep 17 00:00:00 2001 From: thekiwismarthome <134335563+thekiwismarthome@users.noreply.github.com> Date: Mon, 16 Feb 2026 20:05:22 +1300 Subject: [PATCH] Update handlers.py --- .../shopping_list_manager/websocket/handlers.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/custom_components/shopping_list_manager/websocket/handlers.py b/custom_components/shopping_list_manager/websocket/handlers.py index c53e851..2ac0727 100644 --- a/custom_components/shopping_list_manager/websocket/handlers.py +++ b/custom_components/shopping_list_manager/websocket/handlers.py @@ -6,6 +6,7 @@ import voluptuous as vol from homeassistant.components import websocket_api from homeassistant.core import HomeAssistant, callback +from ..const import DOMAIN from ..const import ( WS_TYPE_LISTS_GET_ALL, @@ -49,18 +50,22 @@ _LOGGER = logging.getLogger(__name__) }) @websocket_api.async_response async def ws_get_products_by_ids(hass, connection, msg): - product_ids = msg["product_ids"] + """Return products matching given product IDs.""" - catalog = hass.data[DOMAIN]["catalog"] + product_ids = set(msg["product_ids"]) + + # Catalog is stored as a LIST + catalog = hass.data[DOMAIN].get("catalog", []) products = [ product - for product in catalog.values() - if product["id"] in product_ids + for product in catalog + if str(product.get("id")) in product_ids ] connection.send_result(msg["id"], {"products": products}) + @websocket_api.websocket_command( { vol.Required("type"): WS_TYPE_LISTS_GET_ALL,