mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add shopping_list_item_added event_type (#28334)
* Update __init__.py Added event_type "shopping_list_item_added" with an item tied to it. * Update __init__.py * Update __init__.py Black formatting style * Modified global event variables * Typo fix * Update __init__.py * Formatting changes * More formatting changes * Update __init__.py * Black formatting * Update __init__.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
e0586df602
commit
71a6ea1c10
@ -241,7 +241,7 @@ def websocket_handle_items(hass, connection, msg):
|
||||
def websocket_handle_add(hass, connection, msg):
|
||||
"""Handle add item to shopping_list."""
|
||||
item = hass.data[DOMAIN].async_add(msg["name"])
|
||||
hass.bus.async_fire(EVENT)
|
||||
hass.bus.async_fire(EVENT, {"action": "add", "item": item})
|
||||
connection.send_message(websocket_api.result_message(msg["id"], item))
|
||||
|
||||
|
||||
@ -255,7 +255,7 @@ async def websocket_handle_update(hass, connection, msg):
|
||||
|
||||
try:
|
||||
item = hass.data[DOMAIN].async_update(item_id, data)
|
||||
hass.bus.async_fire(EVENT)
|
||||
hass.bus.async_fire(EVENT, {"action": "update", "item": item})
|
||||
connection.send_message(websocket_api.result_message(msg_id, item))
|
||||
except KeyError:
|
||||
connection.send_message(
|
||||
@ -267,5 +267,5 @@ async def websocket_handle_update(hass, connection, msg):
|
||||
def websocket_handle_clear(hass, connection, msg):
|
||||
"""Handle clearing shopping_list items."""
|
||||
hass.data[DOMAIN].async_clear_completed()
|
||||
hass.bus.async_fire(EVENT)
|
||||
hass.bus.async_fire(EVENT, {"action": "clear"})
|
||||
connection.send_message(websocket_api.result_message(msg["id"]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user