Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate template to register reload service on async_setup (#48273)
- Loading branch information
Showing
14 changed files
with
132 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,11 @@ | ||
"""The template component.""" | ||
from homeassistant.const import SERVICE_RELOAD | ||
from homeassistant.helpers.reload import async_reload_integration_platforms | ||
from homeassistant.helpers.reload import async_setup_reload_service | ||
|
||
from .const import DOMAIN, EVENT_TEMPLATE_RELOADED, PLATFORMS | ||
from .const import DOMAIN, PLATFORMS | ||
|
||
|
||
async def async_setup_reload_service(hass): | ||
"""Create the reload service for the template domain.""" | ||
if hass.services.has_service(DOMAIN, SERVICE_RELOAD): | ||
return | ||
async def async_setup(hass, config): | ||
"""Set up the template integration.""" | ||
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) | ||
|
||
async def _reload_config(call): | ||
"""Reload the template platform config.""" | ||
await async_reload_integration_platforms(hass, DOMAIN, PLATFORMS) | ||
hass.bus.async_fire(EVENT_TEMPLATE_RELOADED, context=call.context) | ||
|
||
hass.helpers.service.async_register_admin_service( | ||
DOMAIN, SERVICE_RELOAD, _reload_config | ||
) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.