mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Ensure service calls are typed [a-d] (#62891)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
942f58593b
commit
de64622f3b
@ -23,6 +23,7 @@ from homeassistant.const import (
|
|||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import event, service
|
from homeassistant.helpers import event, service
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
@ -117,7 +118,7 @@ async def async_setup(hass, config):
|
|||||||
if not entities:
|
if not entities:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def async_handle_alert_service(service_call):
|
async def async_handle_alert_service(service_call: ServiceCall) -> None:
|
||||||
"""Handle calls to alert services."""
|
"""Handle calls to alert services."""
|
||||||
alert_ids = await service.async_extract_entity_ids(hass, service_call)
|
alert_ids = await service.async_extract_entity_ids(hass, service_call)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||||||
CONF_CLIENT_SECRET,
|
CONF_CLIENT_SECRET,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
@ -96,7 +97,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
|
|
||||||
async_add_entities(devs, True)
|
async_add_entities(devs, True)
|
||||||
|
|
||||||
async def send_comfort_feedback(service):
|
async def send_comfort_feedback(service: ServiceCall) -> None:
|
||||||
"""Send comfort feedback."""
|
"""Send comfort feedback."""
|
||||||
device_name = service.data[ATTR_NAME]
|
device_name = service.data[ATTR_NAME]
|
||||||
device = data_connection.find_device_by_room_name(device_name)
|
device = data_connection.find_device_by_room_name(device_name)
|
||||||
@ -110,7 +111,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
schema=SEND_COMFORT_FEEDBACK_SCHEMA,
|
schema=SEND_COMFORT_FEEDBACK_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_comfort_mode(service):
|
async def set_comfort_mode(service: ServiceCall) -> None:
|
||||||
"""Set comfort mode."""
|
"""Set comfort mode."""
|
||||||
device_name = service.data[ATTR_NAME]
|
device_name = service.data[ATTR_NAME]
|
||||||
device = data_connection.find_device_by_room_name(device_name)
|
device = data_connection.find_device_by_room_name(device_name)
|
||||||
@ -121,7 +122,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
DOMAIN, SERVICE_COMFORT_MODE, set_comfort_mode, schema=SET_COMFORT_MODE_SCHEMA
|
DOMAIN, SERVICE_COMFORT_MODE, set_comfort_mode, schema=SET_COMFORT_MODE_SCHEMA
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_temperature_mode(service):
|
async def set_temperature_mode(service: ServiceCall) -> None:
|
||||||
"""Set temperature mode."""
|
"""Set temperature mode."""
|
||||||
device_name = service.data[ATTR_NAME]
|
device_name = service.data[ATTR_NAME]
|
||||||
device = data_connection.find_device_by_room_name(device_name)
|
device = data_connection.find_device_by_room_name(device_name)
|
||||||
|
@ -44,7 +44,7 @@ from homeassistant.const import (
|
|||||||
STATE_PAUSED,
|
STATE_PAUSED,
|
||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
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
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
@ -172,7 +172,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
host.get(CONF_NAME),
|
host.get(CONF_NAME),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_service_handler(service):
|
async def async_service_handler(service: ServiceCall) -> None:
|
||||||
"""Map services to method of Bluesound devices."""
|
"""Map services to method of Bluesound devices."""
|
||||||
if not (method := SERVICE_TO_METHOD.get(service.service)):
|
if not (method := SERVICE_TO_METHOD.get(service.service)):
|
||||||
return
|
return
|
||||||
|
@ -13,7 +13,7 @@ from pycfdns.exceptions import (
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_API_TOKEN, CONF_ZONE
|
from homeassistant.const import CONF_API_TOKEN, CONF_ZONE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
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
|
||||||
@ -49,7 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
except CloudflareException as error:
|
except CloudflareException as error:
|
||||||
_LOGGER.error("Error updating zone %s: %s", entry.data[CONF_ZONE], error)
|
_LOGGER.error("Error updating zone %s: %s", entry.data[CONF_ZONE], error)
|
||||||
|
|
||||||
async def update_records_service(call):
|
async def update_records_service(call: ServiceCall) -> None:
|
||||||
"""Set up service for manual trigger."""
|
"""Set up service for manual trigger."""
|
||||||
try:
|
try:
|
||||||
await _async_update_cloudflare(cfupdate, zone_id)
|
await _async_update_cloudflare(cfupdate, zone_id)
|
||||||
|
@ -15,6 +15,7 @@ from homeassistant.components.light import (
|
|||||||
LIGHT_TURN_ON_SCHEMA,
|
LIGHT_TURN_ON_SCHEMA,
|
||||||
SERVICE_TURN_ON as LIGHT_SERVICE_TURN_ON,
|
SERVICE_TURN_ON as LIGHT_SERVICE_TURN_ON,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ def _get_color(file_handler) -> tuple:
|
|||||||
async def async_setup(hass, hass_config):
|
async def async_setup(hass, hass_config):
|
||||||
"""Set up services for color_extractor integration."""
|
"""Set up services for color_extractor integration."""
|
||||||
|
|
||||||
async def async_handle_service(service_call):
|
async def async_handle_service(service_call: ServiceCall) -> None:
|
||||||
"""Decide which color_extractor method to call based on service."""
|
"""Decide which color_extractor method to call based on service."""
|
||||||
service_data = dict(service_call.data)
|
service_data = dict(service_call.data)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from homeassistant.const import (
|
|||||||
ATTR_FRIENDLY_NAME,
|
ATTR_FRIENDLY_NAME,
|
||||||
EVENT_TIME_CHANGED,
|
EVENT_TIME_CHANGED,
|
||||||
)
|
)
|
||||||
from homeassistant.core import Event, callback as async_callback
|
from homeassistant.core import Event, ServiceCall, callback as async_callback
|
||||||
from homeassistant.helpers.entity import async_generate_entity_id
|
from homeassistant.helpers.entity import async_generate_entity_id
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
from homeassistant.util.async_ import run_callback_threadsafe
|
||||||
@ -212,7 +212,7 @@ class Configurator:
|
|||||||
|
|
||||||
self.hass.bus.async_listen_once(EVENT_TIME_CHANGED, deferred_remove)
|
self.hass.bus.async_listen_once(EVENT_TIME_CHANGED, deferred_remove)
|
||||||
|
|
||||||
async def async_handle_service_call(self, call):
|
async def async_handle_service_call(self, call: ServiceCall) -> None:
|
||||||
"""Handle a configure service call."""
|
"""Handle a configure service call."""
|
||||||
request_id = call.data.get(ATTR_CONFIGURE_ID)
|
request_id = call.data.get(ATTR_CONFIGURE_ID)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ async def async_setup(hass, config):
|
|||||||
"""Register the process service."""
|
"""Register the process service."""
|
||||||
hass.data[DATA_CONFIG] = config
|
hass.data[DATA_CONFIG] = config
|
||||||
|
|
||||||
async def handle_service(service):
|
async def handle_service(service: core.ServiceCall) -> None:
|
||||||
"""Parse text into commands."""
|
"""Parse text into commands."""
|
||||||
text = service.data[ATTR_TEXT]
|
text = service.data[ATTR_TEXT]
|
||||||
_LOGGER.debug("Processing: <%s>", text)
|
_LOGGER.debug("Processing: <%s>", text)
|
||||||
|
@ -5,7 +5,7 @@ import logging
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_DOMAIN
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_DOMAIN
|
||||||
from homeassistant.core import CALLBACK_TYPE, callback
|
from homeassistant.core import CALLBACK_TYPE, ServiceCall, callback
|
||||||
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
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
@ -58,7 +58,7 @@ async def async_setup(hass, config):
|
|||||||
)
|
)
|
||||||
async_track_time_interval_backoff(hass, update_domain_interval, intervals)
|
async_track_time_interval_backoff(hass, update_domain_interval, intervals)
|
||||||
|
|
||||||
async def update_domain_service(call):
|
async def update_domain_service(call: ServiceCall) -> None:
|
||||||
"""Update the DuckDNS entry."""
|
"""Update the DuckDNS entry."""
|
||||||
await _update_duckdns(session, domain, token, txt=call.data[ATTR_TXT])
|
await _update_duckdns(session, domain, token, txt=call.data[ATTR_TXT])
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def dynalite_service(service_call: ServiceCall):
|
async def dynalite_service(service_call: ServiceCall) -> None:
|
||||||
data = service_call.data
|
data = service_call.data
|
||||||
host = data.get(ATTR_HOST, "")
|
host = data.get(ATTR_HOST, "")
|
||||||
bridges = []
|
bridges = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user