mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
Rename service registration method (#146615)
This commit is contained in:
parent
20f5d85800
commit
22a14da19c
@ -14,7 +14,7 @@ from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
|||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import CONF_INSTALLER_CODE, CONF_USER_CODE, DOMAIN
|
from .const import CONF_INSTALLER_CODE, CONF_USER_CODE, DOMAIN
|
||||||
from .services import setup_services
|
from .services import async_setup_services
|
||||||
from .types import BoschAlarmConfigEntry
|
from .types import BoschAlarmConfigEntry
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
@ -29,7 +29,7 @@ PLATFORMS: list[Platform] = [
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up bosch alarm services."""
|
"""Set up bosch alarm services."""
|
||||||
setup_services(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from typing import Any
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
@ -66,7 +66,8 @@ async def async_set_panel_date(call: ServiceCall) -> None:
|
|||||||
) from err
|
) from err
|
||||||
|
|
||||||
|
|
||||||
def setup_services(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Set up the services for the bosch alarm integration."""
|
"""Set up the services for the bosch alarm integration."""
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
@ -12,7 +12,7 @@ from .bridge import DynaliteBridge
|
|||||||
from .const import DOMAIN, LOGGER, PLATFORMS
|
from .const import DOMAIN, LOGGER, PLATFORMS
|
||||||
from .convert_config import convert_config
|
from .convert_config import convert_config
|
||||||
from .panel import async_register_dynalite_frontend
|
from .panel import async_register_dynalite_frontend
|
||||||
from .services import setup_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ type DynaliteConfigEntry = ConfigEntry[DynaliteBridge]
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Dynalite platform."""
|
"""Set up the Dynalite platform."""
|
||||||
setup_services(hass)
|
async_setup_services(hass)
|
||||||
|
|
||||||
await async_register_dynalite_frontend(hass)
|
await async_register_dynalite_frontend(hass)
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ async def _request_channel_level(service_call: ServiceCall) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def setup_services(hass: HomeAssistant) -> None:
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Set up the Dynalite platform."""
|
"""Set up the Dynalite platform."""
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -27,7 +27,7 @@ from .const import (
|
|||||||
SIGNAL_PAIRED_SENSOR_COORDINATOR_ADDED,
|
SIGNAL_PAIRED_SENSOR_COORDINATOR_ADDED,
|
||||||
)
|
)
|
||||||
from .coordinator import GuardianDataUpdateCoordinator
|
from .coordinator import GuardianDataUpdateCoordinator
|
||||||
from .services import setup_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class GuardianData:
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Elexa Guardian component."""
|
"""Set up the Elexa Guardian component."""
|
||||||
setup_services(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,8 +122,9 @@ async def async_upgrade_firmware(call: ServiceCall, data: GuardianData) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_services(hass: HomeAssistant) -> None:
|
@callback
|
||||||
"""Register the Renault services."""
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
|
"""Register the guardian services."""
|
||||||
for service_name, schema, method in (
|
for service_name, schema, method in (
|
||||||
(
|
(
|
||||||
SERVICE_NAME_PAIR_SENSOR,
|
SERVICE_NAME_PAIR_SENSOR,
|
||||||
|
@ -9,9 +9,9 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from . import services
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import HeosConfigEntry, HeosCoordinator
|
from .coordinator import HeosConfigEntry, HeosCoordinator
|
||||||
|
from .services import async_setup_services
|
||||||
|
|
||||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the HEOS component."""
|
"""Set up the HEOS component."""
|
||||||
services.register(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.media_player import ATTR_MEDIA_VOLUME_LEVEL
|
from homeassistant.components.media_player import ATTR_MEDIA_VOLUME_LEVEL
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse
|
from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
config_validation as cv,
|
config_validation as cv,
|
||||||
@ -44,7 +44,8 @@ HEOS_SIGN_IN_SCHEMA = vol.Schema(
|
|||||||
HEOS_SIGN_OUT_SCHEMA = vol.Schema({})
|
HEOS_SIGN_OUT_SCHEMA = vol.Schema({})
|
||||||
|
|
||||||
|
|
||||||
def register(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Register HEOS services."""
|
"""Register HEOS services."""
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -23,7 +23,7 @@ from homeassistant.helpers.typing import ConfigType
|
|||||||
from .api import AsyncConfigEntryAuth
|
from .api import AsyncConfigEntryAuth
|
||||||
from .const import DOMAIN, OLD_NEW_UNIQUE_ID_SUFFIX_MAP
|
from .const import DOMAIN, OLD_NEW_UNIQUE_ID_SUFFIX_MAP
|
||||||
from .coordinator import HomeConnectConfigEntry, HomeConnectCoordinator
|
from .coordinator import HomeConnectConfigEntry, HomeConnectCoordinator
|
||||||
from .services import register_actions
|
from .services import async_setup_services
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ PLATFORMS = [
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up Home Connect component."""
|
"""Set up Home Connect component."""
|
||||||
register_actions(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from aiohomeconnect.model.error import HomeConnectError
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import ATTR_DEVICE_ID
|
from homeassistant.const import ATTR_DEVICE_ID
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
@ -522,7 +522,8 @@ async def async_service_start_program(call: ServiceCall) -> None:
|
|||||||
await _async_service_program(call, True)
|
await _async_service_program(call, True)
|
||||||
|
|
||||||
|
|
||||||
def register_actions(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Register custom actions."""
|
"""Register custom actions."""
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
@ -91,7 +91,7 @@ from .schema import (
|
|||||||
TimeSchema,
|
TimeSchema,
|
||||||
WeatherSchema,
|
WeatherSchema,
|
||||||
)
|
)
|
||||||
from .services import register_knx_services
|
from .services import async_setup_services
|
||||||
from .storage.config_store import STORAGE_KEY as CONFIG_STORAGE_KEY, KNXConfigStore
|
from .storage.config_store import STORAGE_KEY as CONFIG_STORAGE_KEY, KNXConfigStore
|
||||||
from .telegrams import STORAGE_KEY as TELEGRAMS_STORAGE_KEY, Telegrams
|
from .telegrams import STORAGE_KEY as TELEGRAMS_STORAGE_KEY, Telegrams
|
||||||
from .websocket import register_panel
|
from .websocket import register_panel
|
||||||
@ -138,7 +138,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
if (conf := config.get(DOMAIN)) is not None:
|
if (conf := config.get(DOMAIN)) is not None:
|
||||||
hass.data[_KNX_YAML_CONFIG] = dict(conf)
|
hass.data[_KNX_YAML_CONFIG] = dict(conf)
|
||||||
|
|
||||||
register_knx_services(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def register_knx_services(hass: HomeAssistant) -> None:
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Register KNX integration services."""
|
"""Register KNX integration services."""
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -45,7 +45,7 @@ from homeassistant.helpers.typing import ConfigType
|
|||||||
from homeassistant.util.json import JsonObjectType, load_json_object
|
from homeassistant.util.json import JsonObjectType, load_json_object
|
||||||
|
|
||||||
from .const import ATTR_FORMAT, ATTR_IMAGES, CONF_ROOMS_REGEX, DOMAIN, FORMAT_HTML
|
from .const import ATTR_FORMAT, ATTR_IMAGES, CONF_ROOMS_REGEX, DOMAIN, FORMAT_HTML
|
||||||
from .services import register_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
config[CONF_COMMANDS],
|
config[CONF_COMMANDS],
|
||||||
)
|
)
|
||||||
|
|
||||||
register_services(hass)
|
async_setup_services(hass)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.notify import ATTR_DATA, ATTR_MESSAGE, ATTR_TARGET
|
from homeassistant.components.notify import ATTR_DATA, ATTR_MESSAGE, ATTR_TARGET
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -50,7 +50,8 @@ async def _handle_send_message(call: ServiceCall) -> None:
|
|||||||
await matrix_bot.handle_send_message(call)
|
await matrix_bot.handle_send_message(call)
|
||||||
|
|
||||||
|
|
||||||
def register_services(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Set up the Matrix bot component."""
|
"""Set up the Matrix bot component."""
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.helpers.typing import ConfigType
|
|||||||
|
|
||||||
from .const import CONF_LOCALE, DOMAIN, PLATFORMS
|
from .const import CONF_LOCALE, DOMAIN, PLATFORMS
|
||||||
from .renault_hub import RenaultHub
|
from .renault_hub import RenaultHub
|
||||||
from .services import setup_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
type RenaultConfigEntry = ConfigEntry[RenaultHub]
|
type RenaultConfigEntry = ConfigEntry[RenaultHub]
|
||||||
@ -20,7 +20,7 @@ type RenaultConfigEntry = ConfigEntry[RenaultHub]
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Renault component."""
|
"""Set up the Renault component."""
|
||||||
setup_services(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
|
|
||||||
@ -191,7 +191,8 @@ def get_vehicle_proxy(service_call: ServiceCall) -> RenaultVehicleProxy:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_services(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Register the Renault services."""
|
"""Register the Renault services."""
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
@ -20,7 +20,7 @@ from homeassistant.helpers.storage import STORAGE_DIR
|
|||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .services import setup_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ def _migrate_device_identifiers(hass: HomeAssistant, entry_id: str) -> None:
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the actions for the Velbus component."""
|
"""Set up the actions for the Velbus component."""
|
||||||
setup_services(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers import config_validation as cv, selector
|
from homeassistant.helpers import config_validation as cv, selector
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
@ -32,7 +32,8 @@ from .const import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_services(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Register the velbus services."""
|
"""Register the velbus services."""
|
||||||
|
|
||||||
def check_entry_id(interface: str) -> str:
|
def check_entry_id(interface: str) -> str:
|
||||||
|
@ -21,7 +21,7 @@ from homeassistant.helpers.discovery import async_load_platform
|
|||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .services import register_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
ex,
|
ex,
|
||||||
)
|
)
|
||||||
|
|
||||||
register_services(hass)
|
async_setup_services(hass)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
|
async_load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
|
||||||
|
@ -5,7 +5,7 @@ import logging
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ID, ATTR_NAME
|
from homeassistant.const import ATTR_ID, ATTR_NAME
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
@ -32,7 +32,8 @@ def _set_active_state(call: ServiceCall) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def register_services(hass: HomeAssistant) -> None:
|
@callback
|
||||||
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Register ZoneMinder services."""
|
"""Register ZoneMinder services."""
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user