mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Ensure admin service calls are typed (#63093)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
34e732ebc1
commit
803eaa8e22
@ -39,7 +39,7 @@ async def async_setup_ha_cast(
|
|||||||
else:
|
else:
|
||||||
refresh_token = await hass.auth.async_create_refresh_token(user)
|
refresh_token = await hass.auth.async_create_refresh_token(user)
|
||||||
|
|
||||||
async def handle_show_view(call: core.ServiceCall):
|
async def handle_show_view(call: core.ServiceCall) -> None:
|
||||||
"""Handle a Show View service call."""
|
"""Handle a Show View service call."""
|
||||||
hass_url = get_url(hass, require_ssl=True, prefer_external=True)
|
hass_url = get_url(hass, require_ssl=True, prefer_external=True)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||||||
CONF_REGION,
|
CONF_REGION,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv, entityfilter
|
from homeassistant.helpers import config_validation as cv, entityfilter
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
@ -197,7 +197,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
_remote_handle_prefs_updated(cloud)
|
_remote_handle_prefs_updated(cloud)
|
||||||
|
|
||||||
async def _service_handler(service):
|
async def _service_handler(service: ServiceCall) -> None:
|
||||||
"""Handle service for cloud."""
|
"""Handle service for cloud."""
|
||||||
if service.service == SERVICE_REMOTE_CONNECT:
|
if service.service == SERVICE_REMOTE_CONNECT:
|
||||||
await prefs.async_update(remote_enabled=True)
|
await prefs.async_update(remote_enabled=True)
|
||||||
|
@ -136,7 +136,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
|
|||||||
ha.DOMAIN, SERVICE_TOGGLE, async_handle_turn_service, schema=service_schema
|
ha.DOMAIN, SERVICE_TOGGLE, async_handle_turn_service, schema=service_schema
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_handle_core_service(call):
|
async def async_handle_core_service(call: ha.ServiceCall) -> None:
|
||||||
"""Service handler for handling core services."""
|
"""Service handler for handling core services."""
|
||||||
if call.service in SHUTDOWN_SERVICES and recorder.async_migration_in_progress(
|
if call.service in SHUTDOWN_SERVICES and recorder.async_migration_in_progress(
|
||||||
hass
|
hass
|
||||||
@ -220,7 +220,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
|
|||||||
schema=SCHEMA_UPDATE_ENTITY,
|
schema=SCHEMA_UPDATE_ENTITY,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_handle_reload_config(call):
|
async def async_handle_reload_config(call: ha.ServiceCall) -> None:
|
||||||
"""Service handler for reloading core config."""
|
"""Service handler for reloading core config."""
|
||||||
try:
|
try:
|
||||||
conf = await conf_util.async_hass_config_yaml(hass)
|
conf = await conf_util.async_hass_config_yaml(hass)
|
||||||
@ -235,7 +235,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
|
|||||||
ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG, async_handle_reload_config
|
ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG, async_handle_reload_config
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_location(call):
|
async def async_set_location(call: ha.ServiceCall) -> None:
|
||||||
"""Service handler to set location."""
|
"""Service handler to set location."""
|
||||||
await hass.config.async_update(
|
await hass.config.async_update(
|
||||||
latitude=call.data[ATTR_LATITUDE], longitude=call.data[ATTR_LONGITUDE]
|
latitude=call.data[ATTR_LATITUDE], longitude=call.data[ATTR_LONGITUDE]
|
||||||
@ -248,7 +248,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
|
|||||||
vol.Schema({ATTR_LATITUDE: cv.latitude, ATTR_LONGITUDE: cv.longitude}),
|
vol.Schema({ATTR_LATITUDE: cv.latitude, ATTR_LONGITUDE: cv.longitude}),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_handle_reload_config_entry(call):
|
async def async_handle_reload_config_entry(call: ha.ServiceCall) -> None:
|
||||||
"""Service handler for reloading a config entry."""
|
"""Service handler for reloading a config entry."""
|
||||||
reload_entries = set()
|
reload_entries = set()
|
||||||
if ATTR_ENTRY_ID in call.data:
|
if ATTR_ENTRY_ID in call.data:
|
||||||
|
@ -417,7 +417,7 @@ def _async_register_events_and_services(hass: HomeAssistant):
|
|||||||
schema=UNPAIR_SERVICE_SCHEMA,
|
schema=UNPAIR_SERVICE_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _handle_homekit_reload(service):
|
async def _handle_homekit_reload(service: ServiceCall) -> None:
|
||||||
"""Handle start HomeKit service call."""
|
"""Handle start HomeKit service call."""
|
||||||
config = await async_integration_yaml_config(hass, DOMAIN)
|
config = await async_integration_yaml_config(hass, DOMAIN)
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
|
|
||||||
hass.bus.async_listen(EVENT_USER_REMOVED, _handle_user_removed)
|
hass.bus.async_listen(EVENT_USER_REMOVED, _handle_user_removed)
|
||||||
|
|
||||||
async def async_reload_yaml(call: ServiceCall):
|
async def async_reload_yaml(call: ServiceCall) -> None:
|
||||||
"""Reload YAML."""
|
"""Reload YAML."""
|
||||||
conf = await entity_component.async_prepare_reload(skip_reset=True)
|
conf = await entity_component.async_prepare_reload(skip_reset=True)
|
||||||
if conf is None:
|
if conf is None:
|
||||||
|
@ -56,15 +56,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
lock = asyncio.Lock()
|
lock = asyncio.Lock()
|
||||||
domain_data = hass.data[DOMAIN] = {}
|
domain_data = hass.data[DOMAIN] = {}
|
||||||
|
|
||||||
async def _async_run_profile(call: ServiceCall):
|
async def _async_run_profile(call: ServiceCall) -> None:
|
||||||
async with lock:
|
async with lock:
|
||||||
await _async_generate_profile(hass, call)
|
await _async_generate_profile(hass, call)
|
||||||
|
|
||||||
async def _async_run_memory_profile(call: ServiceCall):
|
async def _async_run_memory_profile(call: ServiceCall) -> None:
|
||||||
async with lock:
|
async with lock:
|
||||||
await _async_generate_memory_profile(hass, call)
|
await _async_generate_memory_profile(hass, call)
|
||||||
|
|
||||||
async def _async_start_log_objects(call: ServiceCall):
|
async def _async_start_log_objects(call: ServiceCall) -> None:
|
||||||
if LOG_INTERVAL_SUB in domain_data:
|
if LOG_INTERVAL_SUB in domain_data:
|
||||||
domain_data[LOG_INTERVAL_SUB]()
|
domain_data[LOG_INTERVAL_SUB]()
|
||||||
|
|
||||||
@ -78,14 +78,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass, _log_objects, call.data[CONF_SCAN_INTERVAL]
|
hass, _log_objects, call.data[CONF_SCAN_INTERVAL]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_stop_log_objects(call: ServiceCall):
|
async def _async_stop_log_objects(call: ServiceCall) -> None:
|
||||||
if LOG_INTERVAL_SUB not in domain_data:
|
if LOG_INTERVAL_SUB not in domain_data:
|
||||||
return
|
return
|
||||||
|
|
||||||
hass.components.persistent_notification.async_dismiss("profile_object_logging")
|
hass.components.persistent_notification.async_dismiss("profile_object_logging")
|
||||||
domain_data.pop(LOG_INTERVAL_SUB)()
|
domain_data.pop(LOG_INTERVAL_SUB)()
|
||||||
|
|
||||||
def _dump_log_objects(call: ServiceCall):
|
def _dump_log_objects(call: ServiceCall) -> None:
|
||||||
obj_type = call.data[CONF_TYPE]
|
obj_type = call.data[CONF_TYPE]
|
||||||
|
|
||||||
_LOGGER.critical(
|
_LOGGER.critical(
|
||||||
|
@ -11,7 +11,7 @@ from homeassistant.const import (
|
|||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
SERVICE_RELOAD,
|
SERVICE_RELOAD,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CoreState, Event, callback
|
from homeassistant.core import CoreState, Event, ServiceCall, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
discovery,
|
discovery,
|
||||||
@ -31,7 +31,7 @@ async def async_setup(hass, config):
|
|||||||
if DOMAIN in config:
|
if DOMAIN in config:
|
||||||
await _process_config(hass, config)
|
await _process_config(hass, config)
|
||||||
|
|
||||||
async def _reload_config(call: Event) -> None:
|
async def _reload_config(call: Event | ServiceCall) -> None:
|
||||||
"""Reload top-level + platforms."""
|
"""Reload top-level + platforms."""
|
||||||
try:
|
try:
|
||||||
unprocessed_conf = await conf_util.async_hass_config_yaml(hass)
|
unprocessed_conf = await conf_util.async_hass_config_yaml(hass)
|
||||||
|
@ -14,7 +14,7 @@ import zigpy.zdo.types as zdo_types
|
|||||||
|
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api
|
||||||
from homeassistant.const import ATTR_COMMAND, ATTR_NAME
|
from homeassistant.const import ATTR_COMMAND, ATTR_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
@ -945,7 +945,7 @@ def async_load_api(hass):
|
|||||||
zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
||||||
application_controller = zha_gateway.application_controller
|
application_controller = zha_gateway.application_controller
|
||||||
|
|
||||||
async def permit(service):
|
async def permit(service: ServiceCall) -> None:
|
||||||
"""Allow devices to join this network."""
|
"""Allow devices to join this network."""
|
||||||
duration = service.data[ATTR_DURATION]
|
duration = service.data[ATTR_DURATION]
|
||||||
ieee = service.data.get(ATTR_IEEE)
|
ieee = service.data.get(ATTR_IEEE)
|
||||||
@ -976,7 +976,7 @@ def async_load_api(hass):
|
|||||||
DOMAIN, SERVICE_PERMIT, permit, schema=SERVICE_SCHEMAS[SERVICE_PERMIT]
|
DOMAIN, SERVICE_PERMIT, permit, schema=SERVICE_SCHEMAS[SERVICE_PERMIT]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def remove(service):
|
async def remove(service: ServiceCall) -> None:
|
||||||
"""Remove a node from the network."""
|
"""Remove a node from the network."""
|
||||||
ieee = service.data[ATTR_IEEE]
|
ieee = service.data[ATTR_IEEE]
|
||||||
zha_gateway: ZhaGatewayType = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
zha_gateway: ZhaGatewayType = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
||||||
@ -994,7 +994,7 @@ def async_load_api(hass):
|
|||||||
DOMAIN, SERVICE_REMOVE, remove, schema=SERVICE_SCHEMAS[IEEE_SERVICE]
|
DOMAIN, SERVICE_REMOVE, remove, schema=SERVICE_SCHEMAS[IEEE_SERVICE]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_zigbee_cluster_attributes(service):
|
async def set_zigbee_cluster_attributes(service: ServiceCall) -> None:
|
||||||
"""Set zigbee attribute for cluster on zha entity."""
|
"""Set zigbee attribute for cluster on zha entity."""
|
||||||
ieee = service.data.get(ATTR_IEEE)
|
ieee = service.data.get(ATTR_IEEE)
|
||||||
endpoint_id = service.data.get(ATTR_ENDPOINT_ID)
|
endpoint_id = service.data.get(ATTR_ENDPOINT_ID)
|
||||||
@ -1041,7 +1041,7 @@ def async_load_api(hass):
|
|||||||
schema=SERVICE_SCHEMAS[SERVICE_SET_ZIGBEE_CLUSTER_ATTRIBUTE],
|
schema=SERVICE_SCHEMAS[SERVICE_SET_ZIGBEE_CLUSTER_ATTRIBUTE],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def issue_zigbee_cluster_command(service):
|
async def issue_zigbee_cluster_command(service: ServiceCall) -> None:
|
||||||
"""Issue command on zigbee cluster on zha entity."""
|
"""Issue command on zigbee cluster on zha entity."""
|
||||||
ieee = service.data.get(ATTR_IEEE)
|
ieee = service.data.get(ATTR_IEEE)
|
||||||
endpoint_id = service.data.get(ATTR_ENDPOINT_ID)
|
endpoint_id = service.data.get(ATTR_ENDPOINT_ID)
|
||||||
@ -1092,7 +1092,7 @@ def async_load_api(hass):
|
|||||||
schema=SERVICE_SCHEMAS[SERVICE_ISSUE_ZIGBEE_CLUSTER_COMMAND],
|
schema=SERVICE_SCHEMAS[SERVICE_ISSUE_ZIGBEE_CLUSTER_COMMAND],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def issue_zigbee_group_command(service):
|
async def issue_zigbee_group_command(service: ServiceCall) -> None:
|
||||||
"""Issue command on zigbee cluster on a zigbee group."""
|
"""Issue command on zigbee cluster on a zigbee group."""
|
||||||
group_id = service.data.get(ATTR_GROUP)
|
group_id = service.data.get(ATTR_GROUP)
|
||||||
cluster_id = service.data.get(ATTR_CLUSTER_ID)
|
cluster_id = service.data.get(ATTR_CLUSTER_ID)
|
||||||
@ -1138,7 +1138,7 @@ def async_load_api(hass):
|
|||||||
}
|
}
|
||||||
return cluster_channels.get(CHANNEL_IAS_WD)
|
return cluster_channels.get(CHANNEL_IAS_WD)
|
||||||
|
|
||||||
async def warning_device_squawk(service):
|
async def warning_device_squawk(service: ServiceCall) -> None:
|
||||||
"""Issue the squawk command for an IAS warning device."""
|
"""Issue the squawk command for an IAS warning device."""
|
||||||
ieee = service.data[ATTR_IEEE]
|
ieee = service.data[ATTR_IEEE]
|
||||||
mode = service.data.get(ATTR_WARNING_DEVICE_MODE)
|
mode = service.data.get(ATTR_WARNING_DEVICE_MODE)
|
||||||
@ -1177,7 +1177,7 @@ def async_load_api(hass):
|
|||||||
schema=SERVICE_SCHEMAS[SERVICE_WARNING_DEVICE_SQUAWK],
|
schema=SERVICE_SCHEMAS[SERVICE_WARNING_DEVICE_SQUAWK],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def warning_device_warn(service):
|
async def warning_device_warn(service: ServiceCall) -> None:
|
||||||
"""Issue the warning command for an IAS warning device."""
|
"""Issue the warning command for an IAS warning device."""
|
||||||
ieee = service.data[ATTR_IEEE]
|
ieee = service.data[ATTR_IEEE]
|
||||||
mode = service.data.get(ATTR_WARNING_DEVICE_MODE)
|
mode = service.data.get(ATTR_WARNING_DEVICE_MODE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user