Home Assistant Unofficial Reference 2024.12.1
helpers.py
Go to the documentation of this file.
1 """Tessie helper functions."""
2 
3 from typing import Any
4 
5 from tesla_fleet_api.exceptions import TeslaFleetError
6 
7 from homeassistant.exceptions import HomeAssistantError
8 
9 from . import _LOGGER
10 from .const import DOMAIN
11 
12 
13 async def handle_command(command) -> dict[str, Any]:
14  """Handle a command."""
15  try:
16  result = await command
17  except TeslaFleetError as e:
18  raise HomeAssistantError(
19  translation_domain=DOMAIN,
20  translation_key="command_failed",
21  translation_placeholders={"message": e.message},
22  ) from e
23  _LOGGER.debug("Command result: %s", result)
24  return result
dict[str, Any] handle_command(command)
Definition: helpers.py:13