mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Ensure service calls are typed [s-u] (#62922)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
656d383ba6
commit
92ace6c2e8
@ -22,7 +22,7 @@ from homeassistant.const import (
|
|||||||
DATA_MEGABYTES,
|
DATA_MEGABYTES,
|
||||||
DATA_RATE_MEGABYTES_PER_SECOND,
|
DATA_RATE_MEGABYTES_PER_SECOND,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -225,7 +225,7 @@ def async_setup_sabnzbd(hass, sab_api, config, name):
|
|||||||
discovery.async_load_platform(hass, "sensor", DOMAIN, {}, config)
|
discovery.async_load_platform(hass, "sensor", DOMAIN, {}, config)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_service_handler(service):
|
async def async_service_handler(service: ServiceCall) -> None:
|
||||||
"""Handle service calls."""
|
"""Handle service calls."""
|
||||||
if service.service == SERVICE_PAUSE:
|
if service.service == SERVICE_PAUSE:
|
||||||
await sab_api_data.async_pause_queue()
|
await sab_api_data.async_pause_queue()
|
||||||
|
@ -40,7 +40,7 @@ def async_load_screenlogic_services(hass: HomeAssistant):
|
|||||||
if hass.config_entries.async_get_entry(entry_id).domain == DOMAIN
|
if hass.config_entries.async_get_entry(entry_id).domain == DOMAIN
|
||||||
]
|
]
|
||||||
|
|
||||||
async def async_set_color_mode(service_call: ServiceCall):
|
async def async_set_color_mode(service_call: ServiceCall) -> None:
|
||||||
if not (
|
if not (
|
||||||
screenlogic_entry_ids := await extract_screenlogic_config_entry_ids(
|
screenlogic_entry_ids := await extract_screenlogic_config_entry_ids(
|
||||||
service_call
|
service_call
|
||||||
|
@ -26,7 +26,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.helpers import extract_domain_configs
|
from homeassistant.helpers import extract_domain_configs
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.config_validation import make_entity_service_schema
|
from homeassistant.helpers.config_validation import make_entity_service_schema
|
||||||
@ -170,14 +170,14 @@ async def async_setup(hass, config):
|
|||||||
if not await _async_process_config(hass, config, component):
|
if not await _async_process_config(hass, config, component):
|
||||||
await async_get_blueprints(hass).async_populate()
|
await async_get_blueprints(hass).async_populate()
|
||||||
|
|
||||||
async def reload_service(service):
|
async def reload_service(service: ServiceCall) -> None:
|
||||||
"""Call a service to reload scripts."""
|
"""Call a service to reload scripts."""
|
||||||
if (conf := await component.async_prepare_reload()) is None:
|
if (conf := await component.async_prepare_reload()) is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
await _async_process_config(hass, conf, component)
|
await _async_process_config(hass, conf, component)
|
||||||
|
|
||||||
async def turn_on_service(service):
|
async def turn_on_service(service: ServiceCall) -> None:
|
||||||
"""Call a service to turn script on."""
|
"""Call a service to turn script on."""
|
||||||
variables = service.data.get(ATTR_VARIABLES)
|
variables = service.data.get(ATTR_VARIABLES)
|
||||||
for script_entity in await component.async_extract_from_service(service):
|
for script_entity in await component.async_extract_from_service(service):
|
||||||
@ -185,7 +185,7 @@ async def async_setup(hass, config):
|
|||||||
variables=variables, context=service.context, wait=False
|
variables=variables, context=service.context, wait=False
|
||||||
)
|
)
|
||||||
|
|
||||||
async def turn_off_service(service):
|
async def turn_off_service(service: ServiceCall) -> None:
|
||||||
"""Cancel a script."""
|
"""Cancel a script."""
|
||||||
# Stopping a script is ok to be done in parallel
|
# Stopping a script is ok to be done in parallel
|
||||||
script_entities = await component.async_extract_from_service(service)
|
script_entities = await component.async_extract_from_service(service)
|
||||||
@ -200,7 +200,7 @@ async def async_setup(hass, config):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def toggle_service(service):
|
async def toggle_service(service: ServiceCall) -> None:
|
||||||
"""Toggle a script."""
|
"""Toggle a script."""
|
||||||
for script_entity in await component.async_extract_from_service(service):
|
for script_entity in await component.async_extract_from_service(service):
|
||||||
await script_entity.async_toggle(context=service.context, wait=False)
|
await script_entity.async_toggle(context=service.context, wait=False)
|
||||||
@ -266,7 +266,7 @@ async def _async_process_config(hass, config, component) -> bool:
|
|||||||
|
|
||||||
await component.async_add_entities(entities)
|
await component.async_add_entities(entities)
|
||||||
|
|
||||||
async def service_handler(service):
|
async def service_handler(service: ServiceCall) -> None:
|
||||||
"""Execute a service call to script.<script name>."""
|
"""Execute a service call to script.<script name>."""
|
||||||
entity_id = ENTITY_ID_FORMAT.format(service.service)
|
entity_id = ENTITY_ID_FORMAT.format(service.service)
|
||||||
script_entity = component.get_entity(entity_id)
|
script_entity = component.get_entity(entity_id)
|
||||||
|
@ -36,7 +36,7 @@ from homeassistant.const import (
|
|||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import (
|
from homeassistant.helpers.entity_platform import (
|
||||||
@ -116,7 +116,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
async def async_assume_state(service):
|
async def async_assume_state(service: ServiceCall) -> None:
|
||||||
"""Set state according to external service call.."""
|
"""Set state according to external service call.."""
|
||||||
if entity_ids := service.data.get(ATTR_ENTITY_ID):
|
if entity_ids := service.data.get(ATTR_ENTITY_ID):
|
||||||
target_climate = [
|
target_climate = [
|
||||||
|
@ -9,7 +9,7 @@ from homeassistant import config_entries
|
|||||||
from homeassistant.components import http, websocket_api
|
from homeassistant.components import http, websocket_api
|
||||||
from homeassistant.components.http.data_validator import RequestDataValidator
|
from homeassistant.components.http.data_validator import RequestDataValidator
|
||||||
from homeassistant.const import ATTR_NAME
|
from homeassistant.const import 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.util.json import load_json, save_json
|
from homeassistant.util.json import load_json, save_json
|
||||||
|
|
||||||
@ -79,13 +79,13 @@ async def async_setup(hass, config):
|
|||||||
async def async_setup_entry(hass, config_entry):
|
async def async_setup_entry(hass, config_entry):
|
||||||
"""Set up shopping list from config flow."""
|
"""Set up shopping list from config flow."""
|
||||||
|
|
||||||
async def add_item_service(call):
|
async def add_item_service(call: ServiceCall) -> None:
|
||||||
"""Add an item with `name`."""
|
"""Add an item with `name`."""
|
||||||
data = hass.data[DOMAIN]
|
data = hass.data[DOMAIN]
|
||||||
if (name := call.data.get(ATTR_NAME)) is not None:
|
if (name := call.data.get(ATTR_NAME)) is not None:
|
||||||
await data.async_add(name)
|
await data.async_add(name)
|
||||||
|
|
||||||
async def complete_item_service(call):
|
async def complete_item_service(call: ServiceCall) -> None:
|
||||||
"""Mark the item provided via `name` as completed."""
|
"""Mark the item provided via `name` as completed."""
|
||||||
data = hass.data[DOMAIN]
|
data = hass.data[DOMAIN]
|
||||||
if (name := call.data.get(ATTR_NAME)) is None:
|
if (name := call.data.get(ATTR_NAME)) is None:
|
||||||
@ -97,7 +97,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
else:
|
else:
|
||||||
await data.async_update(item["id"], {"name": name, "complete": True})
|
await data.async_update(item["id"], {"name": name, "complete": True})
|
||||||
|
|
||||||
async def incomplete_item_service(call):
|
async def incomplete_item_service(call: ServiceCall) -> None:
|
||||||
"""Mark the item provided via `name` as incomplete."""
|
"""Mark the item provided via `name` as incomplete."""
|
||||||
data = hass.data[DOMAIN]
|
data = hass.data[DOMAIN]
|
||||||
if (name := call.data.get(ATTR_NAME)) is None:
|
if (name := call.data.get(ATTR_NAME)) is None:
|
||||||
@ -109,15 +109,15 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
else:
|
else:
|
||||||
await data.async_update(item["id"], {"name": name, "complete": False})
|
await data.async_update(item["id"], {"name": name, "complete": False})
|
||||||
|
|
||||||
async def complete_all_service(call):
|
async def complete_all_service(call: ServiceCall) -> None:
|
||||||
"""Mark all items in the list as complete."""
|
"""Mark all items in the list as complete."""
|
||||||
await data.async_update_list({"complete": True})
|
await data.async_update_list({"complete": True})
|
||||||
|
|
||||||
async def incomplete_all_service(call):
|
async def incomplete_all_service(call: ServiceCall) -> None:
|
||||||
"""Mark all items in the list as incomplete."""
|
"""Mark all items in the list as incomplete."""
|
||||||
await data.async_update_list({"complete": False})
|
await data.async_update_list({"complete": False})
|
||||||
|
|
||||||
async def clear_completed_items_service(call):
|
async def clear_completed_items_service(call: ServiceCall) -> None:
|
||||||
"""Clear all completed items from the list."""
|
"""Clear all completed items from the list."""
|
||||||
await data.async_clear_completed()
|
await data.async_clear_completed()
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import logging
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv, intent
|
from homeassistant.helpers import config_validation as cv, intent
|
||||||
|
|
||||||
DOMAIN = "snips"
|
DOMAIN = "snips"
|
||||||
@ -159,7 +160,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
await mqtt.async_subscribe(hass, INTENT_TOPIC, message_received)
|
await mqtt.async_subscribe(hass, INTENT_TOPIC, message_received)
|
||||||
|
|
||||||
async def snips_say(call):
|
async def snips_say(call: ServiceCall) -> None:
|
||||||
"""Send a Snips notification message."""
|
"""Send a Snips notification message."""
|
||||||
notification = {
|
notification = {
|
||||||
"siteId": call.data.get(ATTR_SITE_ID, "default"),
|
"siteId": call.data.get(ATTR_SITE_ID, "default"),
|
||||||
@ -171,7 +172,7 @@ async def async_setup(hass, config):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
async def snips_say_action(call):
|
async def snips_say_action(call: ServiceCall) -> None:
|
||||||
"""Send a Snips action message."""
|
"""Send a Snips action message."""
|
||||||
notification = {
|
notification = {
|
||||||
"siteId": call.data.get(ATTR_SITE_ID, "default"),
|
"siteId": call.data.get(ATTR_SITE_ID, "default"),
|
||||||
@ -188,11 +189,11 @@ async def async_setup(hass, config):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
async def feedback_on(call):
|
async def feedback_on(call: ServiceCall) -> None:
|
||||||
"""Turn feedback sounds on."""
|
"""Turn feedback sounds on."""
|
||||||
await async_set_feedback(call.data.get(ATTR_SITE_ID), True)
|
await async_set_feedback(call.data.get(ATTR_SITE_ID), True)
|
||||||
|
|
||||||
async def feedback_off(call):
|
async def feedback_off(call: ServiceCall) -> None:
|
||||||
"""Turn feedback sounds off."""
|
"""Turn feedback sounds off."""
|
||||||
await async_set_feedback(call.data.get(ATTR_SITE_ID), False)
|
await async_set_feedback(call.data.get(ATTR_SITE_ID), False)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import speedtest
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STARTED
|
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STARTED
|
||||||
from homeassistant.core import CoreState, HomeAssistant
|
from homeassistant.core import CoreState, HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class SpeedTestDataCoordinator(DataUpdateCoordinator):
|
|||||||
except speedtest.SpeedtestException as err:
|
except speedtest.SpeedtestException as err:
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
async def request_update(call):
|
async def request_update(call: ServiceCall) -> None:
|
||||||
"""Request update."""
|
"""Request update."""
|
||||||
await self.async_request_refresh()
|
await self.async_request_refresh()
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
"""The StarLine component."""
|
"""The StarLine component."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_SCAN_INTERVAL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
|
||||||
from .account import StarlineAccount
|
from .account import StarlineAccount
|
||||||
@ -39,19 +41,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
async def async_set_scan_interval(call):
|
async def async_set_scan_interval(call: ServiceCall) -> None:
|
||||||
"""Set scan interval."""
|
"""Set scan interval."""
|
||||||
options = dict(entry.options)
|
options = dict(entry.options)
|
||||||
options[CONF_SCAN_INTERVAL] = call.data[CONF_SCAN_INTERVAL]
|
options[CONF_SCAN_INTERVAL] = call.data[CONF_SCAN_INTERVAL]
|
||||||
hass.config_entries.async_update_entry(entry=entry, options=options)
|
hass.config_entries.async_update_entry(entry=entry, options=options)
|
||||||
|
|
||||||
async def async_set_scan_obd_interval(call):
|
async def async_set_scan_obd_interval(call: ServiceCall) -> None:
|
||||||
"""Set OBD info scan interval."""
|
"""Set OBD info scan interval."""
|
||||||
options = dict(entry.options)
|
options = dict(entry.options)
|
||||||
options[CONF_SCAN_OBD_INTERVAL] = call.data[CONF_SCAN_INTERVAL]
|
options[CONF_SCAN_OBD_INTERVAL] = call.data[CONF_SCAN_INTERVAL]
|
||||||
hass.config_entries.async_update_entry(entry=entry, options=options)
|
hass.config_entries.async_update_entry(entry=entry, options=options)
|
||||||
|
|
||||||
async def async_update(call=None):
|
async def async_update(call: ServiceCall | None = None) -> None:
|
||||||
"""Update all data."""
|
"""Update all data."""
|
||||||
await account.update()
|
await account.update()
|
||||||
await account.update_obd()
|
await account.update_obd()
|
||||||
|
@ -22,7 +22,7 @@ from homeassistant.const import (
|
|||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import (
|
from homeassistant.exceptions import (
|
||||||
ConfigEntryAuthFailed,
|
ConfigEntryAuthFailed,
|
||||||
ConfigEntryNotReady,
|
ConfigEntryNotReady,
|
||||||
@ -129,7 +129,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise vol.Invalid from exception
|
raise vol.Invalid from exception
|
||||||
raise vol.Invalid(f"Device {device} does not exist")
|
raise vol.Invalid(f"Device {device} does not exist")
|
||||||
|
|
||||||
async def handle_send_command(call):
|
async def handle_send_command(call: ServiceCall) -> None:
|
||||||
"""Handle the send_command service call."""
|
"""Handle the send_command service call."""
|
||||||
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
||||||
call.data[CONF_BRIDGE]
|
call.data[CONF_BRIDGE]
|
||||||
@ -155,7 +155,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise HomeAssistantError("Error sending command") from exception
|
raise HomeAssistantError("Error sending command") from exception
|
||||||
_LOGGER.debug("Sent command. Response message was: %s", response.message)
|
_LOGGER.debug("Sent command. Response message was: %s", response.message)
|
||||||
|
|
||||||
async def handle_open(call):
|
async def handle_open(call: ServiceCall) -> None:
|
||||||
"""Handle the open service call."""
|
"""Handle the open service call."""
|
||||||
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
||||||
call.data[CONF_BRIDGE]
|
call.data[CONF_BRIDGE]
|
||||||
@ -171,7 +171,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise HomeAssistantError("Error sending") from exception
|
raise HomeAssistantError("Error sending") from exception
|
||||||
_LOGGER.debug("Sent open request")
|
_LOGGER.debug("Sent open request")
|
||||||
|
|
||||||
async def handle_send_keypress(call):
|
async def handle_send_keypress(call: ServiceCall) -> None:
|
||||||
"""Handle the send_keypress service call."""
|
"""Handle the send_keypress service call."""
|
||||||
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
||||||
call.data[CONF_BRIDGE]
|
call.data[CONF_BRIDGE]
|
||||||
@ -190,7 +190,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
raise HomeAssistantError("Error sending") from exception
|
raise HomeAssistantError("Error sending") from exception
|
||||||
_LOGGER.debug("Sent keypress request")
|
_LOGGER.debug("Sent keypress request")
|
||||||
|
|
||||||
async def handle_send_text(call):
|
async def handle_send_text(call: ServiceCall) -> None:
|
||||||
"""Handle the send_keypress service call."""
|
"""Handle the send_keypress service call."""
|
||||||
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][
|
||||||
call.data[CONF_BRIDGE]
|
call.data[CONF_BRIDGE]
|
||||||
|
@ -10,7 +10,7 @@ import voluptuous as vol
|
|||||||
from homeassistant import __path__ as HOMEASSISTANT_PATH
|
from homeassistant import __path__ as HOMEASSISTANT_PATH
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE, EVENT_HOMEASSISTANT_STOP
|
||||||
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
|
||||||
|
|
||||||
CONF_MAX_ENTRIES = "max_entries"
|
CONF_MAX_ENTRIES = "max_entries"
|
||||||
@ -225,7 +225,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
hass.http.register_view(AllErrorsView(handler))
|
hass.http.register_view(AllErrorsView(handler))
|
||||||
|
|
||||||
async def async_service_handler(service):
|
async def async_service_handler(service: ServiceCall) -> None:
|
||||||
"""Handle logger services."""
|
"""Handle logger services."""
|
||||||
if service.service == "clear":
|
if service.service == "clear":
|
||||||
handler.records.clear()
|
handler.records.clear()
|
||||||
|
@ -29,6 +29,7 @@ from homeassistant.const import (
|
|||||||
HTTP_BEARER_AUTHENTICATION,
|
HTTP_BEARER_AUTHENTICATION,
|
||||||
HTTP_DIGEST_AUTHENTICATION,
|
HTTP_DIGEST_AUTHENTICATION,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -325,7 +326,7 @@ async def async_setup(hass, config):
|
|||||||
hass, bot, p_config.get(CONF_ALLOWED_CHAT_IDS), p_config.get(ATTR_PARSER)
|
hass, bot, p_config.get(CONF_ALLOWED_CHAT_IDS), p_config.get(ATTR_PARSER)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_send_telegram_message(service):
|
async def async_send_telegram_message(service: ServiceCall) -> None:
|
||||||
"""Handle sending Telegram Bot message service calls."""
|
"""Handle sending Telegram Bot message service calls."""
|
||||||
|
|
||||||
def _render_template_attr(data, attribute):
|
def _render_template_attr(data, attribute):
|
||||||
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||||
@ -203,7 +204,7 @@ class TransmissionClient:
|
|||||||
|
|
||||||
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||||
|
|
||||||
def add_torrent(service):
|
def add_torrent(service: ServiceCall) -> None:
|
||||||
"""Add new torrent to download."""
|
"""Add new torrent to download."""
|
||||||
tm_client = None
|
tm_client = None
|
||||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||||
@ -224,7 +225,7 @@ class TransmissionClient:
|
|||||||
"Could not add torrent: unsupported type or no permission"
|
"Could not add torrent: unsupported type or no permission"
|
||||||
)
|
)
|
||||||
|
|
||||||
def start_torrent(service):
|
def start_torrent(service: ServiceCall) -> None:
|
||||||
"""Start torrent."""
|
"""Start torrent."""
|
||||||
tm_client = None
|
tm_client = None
|
||||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||||
@ -238,7 +239,7 @@ class TransmissionClient:
|
|||||||
tm_client.tm_api.start_torrent(torrent_id)
|
tm_client.tm_api.start_torrent(torrent_id)
|
||||||
tm_client.api.update()
|
tm_client.api.update()
|
||||||
|
|
||||||
def stop_torrent(service):
|
def stop_torrent(service: ServiceCall) -> None:
|
||||||
"""Stop torrent."""
|
"""Stop torrent."""
|
||||||
tm_client = None
|
tm_client = None
|
||||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||||
@ -252,7 +253,7 @@ class TransmissionClient:
|
|||||||
tm_client.tm_api.stop_torrent(torrent_id)
|
tm_client.tm_api.stop_torrent(torrent_id)
|
||||||
tm_client.api.update()
|
tm_client.api.update()
|
||||||
|
|
||||||
def remove_torrent(service):
|
def remove_torrent(service: ServiceCall) -> None:
|
||||||
"""Remove torrent."""
|
"""Remove torrent."""
|
||||||
tm_client = None
|
tm_client = None
|
||||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||||
|
@ -32,7 +32,7 @@ from homeassistant.const import (
|
|||||||
CONF_PLATFORM,
|
CONF_PLATFORM,
|
||||||
PLATFORM_FORMAT,
|
PLATFORM_FORMAT,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_per_platform, discovery
|
from homeassistant.helpers import config_per_platform, discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -172,7 +172,7 @@ async def async_setup(hass, config):
|
|||||||
_LOGGER.exception("Error setting up platform: %s", p_type)
|
_LOGGER.exception("Error setting up platform: %s", p_type)
|
||||||
return
|
return
|
||||||
|
|
||||||
async def async_say_handle(service):
|
async def async_say_handle(service: ServiceCall) -> None:
|
||||||
"""Service handle for say."""
|
"""Service handle for say."""
|
||||||
entity_ids = service.data[ATTR_ENTITY_ID]
|
entity_ids = service.data[ATTR_ENTITY_ID]
|
||||||
message = service.data.get(ATTR_MESSAGE)
|
message = service.data.get(ATTR_MESSAGE)
|
||||||
@ -232,7 +232,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
discovery.async_listen_platform(hass, DOMAIN, async_platform_discovered)
|
discovery.async_listen_platform(hass, DOMAIN, async_platform_discovered)
|
||||||
|
|
||||||
async def async_clear_cache_handle(service):
|
async def async_clear_cache_handle(service: ServiceCall) -> None:
|
||||||
"""Handle clear cache service call."""
|
"""Handle clear cache service call."""
|
||||||
await tts.async_clear_cache()
|
await tts.async_clear_cache()
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
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 callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ def async_setup_services(hass) -> None:
|
|||||||
SERVICE_REMOVE_CLIENTS: async_remove_clients,
|
SERVICE_REMOVE_CLIENTS: async_remove_clients,
|
||||||
}
|
}
|
||||||
|
|
||||||
async def async_call_unifi_service(service_call) -> None:
|
async def async_call_unifi_service(service_call: ServiceCall) -> None:
|
||||||
"""Call correct UniFi service."""
|
"""Call correct UniFi service."""
|
||||||
await services[service_call.service](hass, service_call.data)
|
await services[service_call.service](hass, service_call.data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user