Home Assistant Unofficial Reference 2024.12.1
helper.py
Go to the documentation of this file.
1 """Provide helper functions for the TTS."""
2 
3 from __future__ import annotations
4 
5 from typing import TYPE_CHECKING
6 
7 from homeassistant.core import HomeAssistant
8 
9 from .const import DATA_COMPONENT, DATA_TTS_MANAGER
10 
11 if TYPE_CHECKING:
12  from . import TextToSpeechEntity
13  from .legacy import Provider
14 
15 
17  hass: HomeAssistant, engine: str
18 ) -> TextToSpeechEntity | Provider | None:
19  """Get engine instance."""
20  if entity := hass.data[DATA_COMPONENT].get_entity(engine):
21  return entity
22 
23  return hass.data[DATA_TTS_MANAGER].providers.get(engine)
CalendarEntity get_entity(HomeAssistant hass, str entity_id)
Definition: trigger.py:96
TextToSpeechEntity|Provider|None get_engine_instance(HomeAssistant hass, str engine)
Definition: helper.py:18