Skip to content

Commit

Permalink
Move HASS trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
lexiismadd committed May 1, 2023
1 parent b0ef8b2 commit 874764b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/shopping_list/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ async def add_item_service(call):
if name is not None:
await data.async_add(name)


async def complete_item_service(call):
"""Mark the item provided via `name` as completed."""
data = hass.data[DOMAIN]
Expand Down Expand Up @@ -352,6 +353,7 @@ async def async_add(self, name):
self.items.append(item.to_ha())
#event.fire('shopping_list_updated','add',item)
await self.bring.purchase_item(item)
self.hass.bus.fire("shopping_list_updated", {"action": "add", "item": item})
self.map_items[item.id] = item
await self.sync_bring()
await self.hass.async_add_executor_job(self.save)
Expand Down Expand Up @@ -385,8 +387,9 @@ async def async_update(self, item_id, info):
await self.bring.recent_item(item)
else:
await self.bring.purchase_item(item)
self.hass.bus.fire("shopping_list_updated", {"action": "update", "item": item})
self.update_item(item_id, item)
event.fire('shopping_list_updated','update',item)

await self.sync_bring()
await self.hass.async_add_executor_job(self.save)
return item.to_ha()
Expand Down

0 comments on commit 874764b

Please sign in to comment.