Skip to content

Commit

Permalink
Merge pull request #271 from karwosts/refresh-after-generic
Browse files Browse the repository at this point in the history
Refresh chores/tasks after a generic service
  • Loading branch information
isabellaalstrom authored Apr 19, 2023
2 parents 50fafd4 + cc2f726 commit 073a214
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/grocy/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def wrapper():
coordinator.grocy_api.add_generic(entity_type, data)

await hass.async_add_executor_job(wrapper)
await post_generic_refresh(coordinator, entity_type);


async def async_update_generic_service(hass, coordinator, data):
Expand All @@ -307,6 +308,7 @@ def wrapper():
coordinator.grocy_api.update_generic(entity_type, object_id, data)

await hass.async_add_executor_job(wrapper)
await post_generic_refresh(coordinator, entity_type);


async def async_delete_generic_service(hass, coordinator, data):
Expand All @@ -323,8 +325,13 @@ def wrapper():
coordinator.grocy_api.delete_generic(entity_type, object_id)

await hass.async_add_executor_job(wrapper)
await post_generic_refresh(coordinator, entity_type);


async def post_generic_refresh(coordinator, entity_type):
if entity_type == "tasks" or entity_type == "chores":
await _async_force_update_entity(coordinator, entity_type)

async def async_consume_recipe_service(hass, coordinator, data):
"""Consume a recipe in Grocy."""
recipe_id = data[SERVICE_RECIPE_ID]
Expand Down

0 comments on commit 073a214

Please sign in to comment.