mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Move SABnzbd action setup to async_setup (#132629)
This commit is contained in:
parent
549afbc27e
commit
4bb3d6123d
@ -14,6 +14,7 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
|
|||||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
import homeassistant.helpers.issue_registry as ir
|
import homeassistant.helpers.issue_registry as ir
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_API_KEY,
|
ATTR_API_KEY,
|
||||||
@ -48,6 +49,8 @@ SERVICE_SPEED_SCHEMA = SERVICE_BASE_SCHEMA.extend(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_get_entry_for_service_call(
|
def async_get_entry_for_service_call(
|
||||||
@ -63,17 +66,9 @@ def async_get_entry_for_service_call(
|
|||||||
raise ValueError(f"No api for API key: {call_data_api_key}")
|
raise ValueError(f"No api for API key: {call_data_api_key}")
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: SabnzbdConfigEntry) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the SabNzbd Component."""
|
"""Set up the SabNzbd Component."""
|
||||||
|
|
||||||
sab_api = await get_client(hass, entry.data)
|
|
||||||
if not sab_api:
|
|
||||||
raise ConfigEntryNotReady
|
|
||||||
|
|
||||||
coordinator = SabnzbdUpdateCoordinator(hass, entry, sab_api)
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
|
||||||
entry.runtime_data = coordinator
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def extract_api(
|
def extract_api(
|
||||||
func: Callable[
|
func: Callable[
|
||||||
@ -147,11 +142,22 @@ async def async_setup_entry(hass: HomeAssistant, entry: SabnzbdConfigEntry) -> b
|
|||||||
(SERVICE_RESUME, async_resume_queue, SERVICE_BASE_SCHEMA),
|
(SERVICE_RESUME, async_resume_queue, SERVICE_BASE_SCHEMA),
|
||||||
(SERVICE_SET_SPEED, async_set_queue_speed, SERVICE_SPEED_SCHEMA),
|
(SERVICE_SET_SPEED, async_set_queue_speed, SERVICE_SPEED_SCHEMA),
|
||||||
):
|
):
|
||||||
if hass.services.has_service(DOMAIN, service):
|
|
||||||
continue
|
|
||||||
|
|
||||||
hass.services.async_register(DOMAIN, service, method, schema=schema)
|
hass.services.async_register(DOMAIN, service, method, schema=schema)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(hass: HomeAssistant, entry: SabnzbdConfigEntry) -> bool:
|
||||||
|
"""Set up the SabNzbd Component."""
|
||||||
|
|
||||||
|
sab_api = await get_client(hass, entry.data)
|
||||||
|
if not sab_api:
|
||||||
|
raise ConfigEntryNotReady
|
||||||
|
|
||||||
|
coordinator = SabnzbdUpdateCoordinator(hass, entry, sab_api)
|
||||||
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user