2024-01-25 11:54:47 +00:00
|
|
|
"""Teslemetry context managers."""
|
|
|
|
|
|
|
|
from contextlib import contextmanager
|
|
|
|
|
|
|
|
from tesla_fleet_api.exceptions import TeslaFleetError
|
|
|
|
|
|
|
|
from homeassistant.exceptions import HomeAssistantError
|
|
|
|
|
|
|
|
|
|
|
|
@contextmanager
|
|
|
|
def handle_command():
|
|
|
|
"""Handle wake up and errors."""
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
except TeslaFleetError as e:
|
2024-01-28 20:04:44 +00:00
|
|
|
raise HomeAssistantError("Teslemetry command failed") from e
|