mirror of
https://github.com/thekiwismarthome/shopping-list-manager.git
synced 2026-05-01 11:46:30 +00:00
Update handlers.py
This commit is contained in:
@@ -43,6 +43,24 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
# LIST HANDLERS
|
# LIST HANDLERS
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
@websocket_api.websocket_command({
|
||||||
|
vol.Required("type"): "shopping_list_manager/products/get_by_ids",
|
||||||
|
vol.Required("product_ids"): [str],
|
||||||
|
})
|
||||||
|
@websocket_api.async_response
|
||||||
|
async def ws_get_products_by_ids(hass, connection, msg):
|
||||||
|
product_ids = msg["product_ids"]
|
||||||
|
|
||||||
|
catalog = hass.data[DOMAIN]["catalog"]
|
||||||
|
|
||||||
|
products = [
|
||||||
|
product
|
||||||
|
for product in catalog.values()
|
||||||
|
if product["id"] in product_ids
|
||||||
|
]
|
||||||
|
|
||||||
|
connection.send_result(msg["id"], {"products": products})
|
||||||
|
|
||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
vol.Required("type"): WS_TYPE_LISTS_GET_ALL,
|
vol.Required("type"): WS_TYPE_LISTS_GET_ALL,
|
||||||
|
|||||||
Reference in New Issue
Block a user