Ensure service calls are typed in homeassistant (#62915)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/62999/head
parent
c5bdf858a8
commit
98135d8158
|
@ -55,11 +55,11 @@ SHUTDOWN_SERVICES = (SERVICE_HOMEASSISTANT_STOP, SERVICE_HOMEASSISTANT_RESTART)
|
|||
async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # noqa: C901
|
||||
"""Set up general services related to Home Assistant."""
|
||||
|
||||
async def async_save_persistent_states(service):
|
||||
async def async_save_persistent_states(service: ha.ServiceCall) -> None:
|
||||
"""Handle calls to homeassistant.save_persistent_states."""
|
||||
await restore_state.RestoreStateData.async_save_persistent_states(hass)
|
||||
|
||||
async def async_handle_turn_service(service):
|
||||
async def async_handle_turn_service(service: ha.ServiceCall) -> None:
|
||||
"""Handle calls to homeassistant.turn_on/off."""
|
||||
referenced = async_extract_referenced_entity_ids(hass, service)
|
||||
all_referenced = referenced.referenced | referenced.indirectly_referenced
|
||||
|
@ -175,7 +175,7 @@ async def async_setup(hass: ha.HomeAssistant, config: ConfigType) -> bool: # no
|
|||
if call.service == SERVICE_HOMEASSISTANT_RESTART:
|
||||
asyncio.create_task(hass.async_stop(RESTART_EXIT_CODE))
|
||||
|
||||
async def async_handle_update_service(call):
|
||||
async def async_handle_update_service(call: ha.ServiceCall) -> None:
|
||||
"""Service handler for updating an entity."""
|
||||
if call.context.user_id:
|
||||
user = await hass.auth.async_get_user(call.context.user_id)
|
||||
|
|
|
@ -21,7 +21,13 @@ from homeassistant.const import (
|
|||
STATE_OFF,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, State, callback
|
||||
from homeassistant.core import (
|
||||
DOMAIN as HA_DOMAIN,
|
||||
HomeAssistant,
|
||||
ServiceCall,
|
||||
State,
|
||||
callback,
|
||||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import (
|
||||
config_per_platform,
|
||||
|
@ -121,9 +127,9 @@ _LOGGER = logging.getLogger(__name__)
|
|||
class SceneConfig(NamedTuple):
|
||||
"""Object for storing scene config."""
|
||||
|
||||
id: str
|
||||
id: str | None
|
||||
name: str
|
||||
icon: str
|
||||
icon: str | None
|
||||
states: dict
|
||||
|
||||
|
||||
|
@ -197,7 +203,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
SCENE_DOMAIN, SERVICE_RELOAD, reload_config
|
||||
)
|
||||
|
||||
async def apply_service(call):
|
||||
async def apply_service(call: ServiceCall) -> None:
|
||||
"""Apply a scene."""
|
||||
reproduce_options = {}
|
||||
|
||||
|
@ -225,7 +231,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
),
|
||||
)
|
||||
|
||||
async def create_service(call):
|
||||
async def create_service(call: ServiceCall) -> None:
|
||||
"""Create a scene."""
|
||||
snapshot = call.data[CONF_SNAPSHOT]
|
||||
entities = call.data[CONF_ENTITIES]
|
||||
|
|
Loading…
Reference in New Issue