Skip to content

Commit

Permalink
Add reload integration service
Browse files Browse the repository at this point in the history
  • Loading branch information
itchannel committed Feb 13, 2023
1 parent a1090e4 commit 2038bfd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 18 additions & 2 deletions custom_components/fordpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,18 @@ async def async_refresh_status_service(service_call):
async def async_clear_tokens_service(service_call):
await hass.async_add_executor_job(clear_tokens, hass, service_call, coordinator)

async def async_clear_tokens_service(service_call):
await hass.async_add_executor_job(clear_tokens, hass, service_call, coordinator)

async def handle_reload(service):
"""Handle reload service call."""
_LOGGER.debug("Reloading Integration")

current_entries = hass.config_entries.async_entries(DOMAIN)
reload_tasks = [
hass.config_entries.async_reload(entry.entry_id)
for entry in current_entries
]

await asyncio.gather(*reload_tasks)

hass.services.async_register(
DOMAIN,
Expand All @@ -107,6 +117,12 @@ async def async_clear_tokens_service(service_call):
async_clear_tokens_service,
)

hass.services.async_register(
DOMAIN,
"reload",
handle_reload
)

return True


Expand Down
3 changes: 3 additions & 0 deletions custom_components/fordpass/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ refresh_status:
text:
clear_tokens:
description: "Clear the cached tokens"
reload:
name: Reload
description: "Reload the Fordpass Integration"

0 comments on commit 2038bfd

Please sign in to comment.