Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
Add coronavirus_hessen.refresh service
Browse files Browse the repository at this point in the history
Allows manual refresh of the data from the web.
  • Loading branch information
foosel committed Mar 15, 2020
1 parent a7f7964 commit a8ed930
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion custom_components/coronavirus_hessen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Coronavirus Hessen component."""
# Make sure coordinator is initialized.
await get_coordinator(hass)
coordinator = await get_coordinator(hass)

async def handle_refresh(call):
_LOGGER.info("Refreshing Coronavirus Hessen data...")
await coordinator.async_refresh()

hass.services.async_register(DOMAIN, "refresh", handle_refresh)

return True


Expand Down
2 changes: 2 additions & 0 deletions custom_components/coronavirus_hessen/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refresh:
description: Refreshes the data from the web

0 comments on commit a8ed930

Please sign in to comment.