Update handlers.py

This commit is contained in:
thekiwismarthome
2026-02-16 20:09:54 +13:00
committed by GitHub
parent c9c1d16f08
commit 9d8fd3f63e
@@ -49,23 +49,29 @@ _LOGGER = logging.getLogger(__name__)
vol.Required("product_ids"): [str],
})
@websocket_api.async_response
async def ws_get_products_by_ids(hass, connection, msg):
async def ws_get_products_by_ids(
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: Dict[str, Any],
) -> None:
"""Return products matching given product IDs."""
storage = get_storage(hass)
product_ids = set(msg["product_ids"])
# Catalog is stored as a LIST
catalog = hass.data[DOMAIN].get("catalog", [])
# Get all products from storage
all_products = storage.get_all_products()
products = [
product
for product in catalog
if str(product.get("id")) in product_ids
product.to_dict()
for product in all_products
if product.id in product_ids
]
connection.send_result(msg["id"], {"products": products})
@websocket_api.websocket_command(
{
vol.Required("type"): WS_TYPE_LISTS_GET_ALL,