Plugins API Reference¶
This page contains auto-generated documentation for all Domovoy plugins.
Hass Plugin¶
The main Home Assistant integration plugin. Provides access to entity states, service calls, triggers, and events.
- class domovoy.plugins.hass.ServiceDetails(has_response)[source]¶
Bases:
object- Parameters:
has_response (bool)
- class domovoy.plugins.hass.HassPlugin(name, wrapper, hass_core)[source]¶
Bases:
AppPlugin- Parameters:
name (str)
wrapper (AppWrapper)
hass_core (HassCore)
- get_full_state(entity_id)[source]¶
Get the complete state object for a Home Assistant entity.
- Parameters:
entity_id (
EntityID) – The EntityID to retrieve state for. Can also accept string for backwards compatibility.- Return type:
EntityState- Returns:
EntityState object containing state, attributes, last_changed, and last_updated.
- Raises:
HassUnknownEntityError – If the entity does not exist in the state cache.
- warn_if_entity_doesnt_exists(entity_id)[source]¶
Log a warning if the specified entity or entities don’t exist in the Home Assistant cache.
Useful for debugging typos in entity IDs during development.
- get_entity_id_by_attribute(attribute, value)[source]¶
Find all entities that have a specific attribute with the given value.
- get_all_entities()[source]¶
Get the complete state objects for all entities in the Home Assistant cache.
- Return type:
list[EntityState]- Returns:
List of EntityState objects for every entity known to Home Assistant.
- async fire_event(event_type, event_data=None)[source]¶
Fire a custom event on the Home Assistant event bus.
- Parameters:
event_type (
str) – The type/name of the event to fire.event_data (
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None] |None) – Optional dictionary of data to include with the event.
- Return type:
- async get_service_definitions()[source]¶
Retrieve service definitions from Home Assistant.
- Return type:
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None]- Returns:
Dictionary containing all available services and their schemas.
- async listen_trigger(trigger, callback, oneshot=False, *callback_args, **callback_kwargs)[source]¶
Subscribe to a Home Assistant trigger configuration.
Triggers are HA’s automation system primitives (state, numeric_state, time, etc.).
- Parameters:
trigger (
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None]) – Dictionary containing the trigger configuration (e.g., {“platform”: “state”, “entity_id”: “…”}).callback (
Callable[[Concatenate[dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None],ParamSpec(P, bound=None)]],None|Awaitable[None]]) – Function to call when trigger fires. Receives trigger variables as first argument.oneshot (
bool) – If True, unsubscribe after the first trigger event.*callback_args (
ParamSpecArgs) – Additional positional arguments to pass to callback.**callback_kwargs (
ParamSpecKwargs) – Additional keyword arguments to pass to callback.
- Return type:
- Returns:
Subscription ID string that can be used to cancel the trigger subscription.
- async call_service(service_name, *, return_response=False, throw_on_error=False, **kwargs)[source]¶
Call a Home Assistant service.
Prefer using the typed service stubs (self.services.domain.service_name) over this method.
- Parameters:
service_name (
str) – Service to call in format “domain.service” (e.g., “light.turn_on”).return_response (
bool) – If True, wait for and return the service response data.throw_on_error (
bool) – If True, raise exceptions on errors. If False, log errors without raising.**kwargs (
int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None) – Service data parameters. entity_id can be EntityID or list[EntityID].
- Return type:
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None] |None- Returns:
Service response data if return_response is True and service returns data, otherwise None.
- Raises:
HassApiCommandError – If throw_on_error is True and service call fails.
- async wait_for_state_to_be(entity_id, states, duration=None, timeout=None)[source]¶
Asynchronously wait for an entity to reach one of the specified states.
This is an awaitable method that blocks until the condition is met or timeout occurs.
- Parameters:
entity_id (
EntityID) – The entity to monitor.states (
str|list[str]) – Single state string or list of state strings to wait for.duration (
Interval|None) – If specified, entity must stay in the target state for this duration.timeout (
Interval|None) – Optional timeout interval. Raises asyncio.TimeoutError if exceeded.
- Raises:
asyncio.TimeoutError – If timeout is specified and exceeded before condition is met.
- Return type:
Search for entities and items related to a specific Home Assistant item.
- Parameters:
- Return type:
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None]- Returns:
Dictionary containing related items organized by type.
- async send_raw_command(command_type, command_args)[source]¶
Send a raw WebSocket command directly to Home Assistant.
This is a low-level method for advanced use cases not covered by other plugin methods.
- Parameters:
command_type (
str) – The WebSocket command type to send.command_args (
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None]) – Dictionary of arguments for the command.
- Return type:
dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None] |list[dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID|dict[str,int|float|str|bool|datetime|EntityID|None]] |dict[str,int|float|str|bool|datetime|EntityID|list[int|float|str|bool|datetime|EntityID] |None] |None]]- Returns:
The response from Home Assistant, either a single data dict or list of dicts.
- get_typed_state(entity_id)[source]¶
Get the state of an entity, cast to the entity’s native type.
Uses the EntityID’s type information to parse and cast the state value.
- domovoy.plugins.hass.wrap_entity_id_as_list(val)[source]¶
Convert a single EntityID or sequence of EntityIDs into a list.
Utility function to normalize entity ID arguments that can be either single or multiple values.
Hass Exceptions¶
- exception domovoy.plugins.hass.exceptions.HassApiAuthenticationError[source]¶
Bases:
HassError- Return type:
None
- exception domovoy.plugins.hass.exceptions.HassApiConnectionError[source]¶
Bases:
HassError,DomovoyLogOnlyOnDebugWhenUncaughtError
- exception domovoy.plugins.hass.exceptions.HassApiConnectionResetError[source]¶
Bases:
HassApiConnectionError
- exception domovoy.plugins.hass.exceptions.HassUnknownEntityError(entity_id)[source]¶
Bases:
HassError- Parameters:
entity_id (EntityID)
- Return type:
None
Callbacks Plugin¶
Event listening and scheduling functionality.
- class domovoy.plugins.callbacks.CallbacksPlugin(name, wrapper, register)[source]¶
Bases:
AppPlugin- Parameters:
name (str)
wrapper (AppWrapper)
register (CallbackRegister)
- listen_state(entity_id, callback, *, immediate=False, oneshot=False)[source]¶
- Return type:
- Parameters:
callback (EntityListenerCallbackFull | EntityListenerCallbackWithAttributeAndOldAndNew | EntityListenerCallbackWithEntityIDAndOldAndNew | EntityListenerCallbackWithEntityIDAndAttributeAndNew | EntityListenerCallbackWithEntityIDAndAttributeAndOld | EntityListenerCallbackWithEntityIDAndAttribute | EntityListenerCallbackWithEntityIDAndOld | EntityListenerCallbackWithEntityIDAndNew | EntityListenerCallbackWithAttributeAndOld | EntityListenerCallbackWithAttributeAndNew | EntityListenerCallbackWithOldAndNew | EntityListenerCallbackWithEntityID | EntityListenerCallbackWithAttribute | EntityListenerCallbackWithOld | EntityListenerCallbackWithNew | Callable[[], None | Awaitable[None]])
immediate (bool)
oneshot (bool)
- listen_attribute(entity_id, attribute, callback, *, immediate=False, oneshot=False)[source]¶
- Return type:
- Parameters:
attribute (str)
callback (EntityListenerCallbackFull | EntityListenerCallbackWithAttributeAndOldAndNew | EntityListenerCallbackWithEntityIDAndOldAndNew | EntityListenerCallbackWithEntityIDAndAttributeAndNew | EntityListenerCallbackWithEntityIDAndAttributeAndOld | EntityListenerCallbackWithEntityIDAndAttribute | EntityListenerCallbackWithEntityIDAndOld | EntityListenerCallbackWithEntityIDAndNew | EntityListenerCallbackWithAttributeAndOld | EntityListenerCallbackWithAttributeAndNew | EntityListenerCallbackWithOldAndNew | EntityListenerCallbackWithEntityID | EntityListenerCallbackWithAttribute | EntityListenerCallbackWithOld | EntityListenerCallbackWithNew | Callable[[], None | Awaitable[None]])
immediate (bool)
oneshot (bool)
- listen_state_extended(entity_id, callback, immediate=False, oneshot=False, *callback_args, **callback_kwargs)[source]¶
- Return type:
- Parameters:
callback (Callable[[Concatenate[EntityID, str, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID | dict[str, int | float | str | bool | datetime | EntityID | None]] | dict[str, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID] | None] | None, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID | dict[str, int | float | str | bool | datetime | EntityID | None]] | dict[str, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID] | None] | None, ~P]], None | Awaitable[None]])
immediate (bool)
oneshot (bool)
callback_args (~P)
callback_kwargs (~P)
- listen_attribute_extended(entity_id, attribute, callback, immediate=False, oneshot=False, *callback_args, **callback_kwargs)[source]¶
- Return type:
- Parameters:
attribute (str)
callback (Callable[[Concatenate[EntityID, str, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID | dict[str, int | float | str | bool | datetime | EntityID | None]] | dict[str, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID] | None] | None, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID | dict[str, int | float | str | bool | datetime | EntityID | None]] | dict[str, int | float | str | bool | datetime | EntityID | list[int | float | str | bool | datetime | EntityID] | None] | None, ~P]], None | Awaitable[None]])
immediate (bool)
oneshot (bool)
callback_args (~P)
callback_kwargs (~P)
ServEnts Plugin¶
Modern API for creating Home Assistant entities from Python (recommended).
- class domovoy.plugins.servents.ExtraConfig(*, device_config=None, wait_for_creation=True)[source]¶
Bases:
object- Parameters:
device_config (DeviceConfig | None)
wait_for_creation (bool)
- class domovoy.plugins.servents.ServentsPlugin(name, wrapper)[source]¶
Bases:
AppPlugin- Parameters:
name (str)
wrapper (AppWrapper)
- set_default_device_for_app(device_config)[source]¶
- Return type:
- Parameters:
device_config (DeviceConfig)
- async create_sensor(servent_id, name, *, default_state=None, fixed_attributes=None, entity_category=None, disabled_by_default=False, app_name=None, device_class=None, unit_of_measurement=None, state_class=None, options=None, creation_config=None)[source]¶
- Return type:
- Parameters:
servent_id (str)
name (str)
entity_category (Literal['config', 'diagnostic'] | None)
disabled_by_default (bool)
app_name (str | None)
device_class (Literal['date', 'enum', 'timestamp', 'absolute_humidity', 'apparent_power', 'aqi', 'area', 'atmospheric_pressure', 'battery', 'blood_glucose_concentration', 'carbon_monoxide', 'carbon_dioxide', 'conductivity', 'current', 'data_rate', 'data_size', 'distance', 'duration', 'energy', 'energy_distance', 'energy_storage', 'frequency', 'gas', 'humidity', 'illuminance', 'irradiance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'ph', 'pm1', 'pm10', 'pm25', 'pm4', 'power_factor', 'power', 'precipitation', 'precipitation_intensity', 'pressure', 'reactive_energy', 'reactive_power', 'signal_strength', 'sound_pressure', 'speed', 'sulphur_dioxide', 'temperature', 'temperature_delta', 'volatile_organic_compounds', 'volatile_organic_compounds_parts', 'voltage', 'volume', 'volume_storage', 'volume_flow_rate', 'water', 'weight', 'wind_direction', 'wind_speed'] | None)
unit_of_measurement (str | None)
state_class (Literal['measurement', 'measurement_angle', 'total', 'total_increasing'] | None)
creation_config (ExtraConfig | None)
- async create_threshold_binary_sensor(servent_id, name, entity_id, *, lower=None, upper=None, hysteresis=0.0, default_state=None, fixed_attributes=None, entity_category=None, disabled_by_default=False, app_name=None, device_class=None, creation_config=None)[source]¶
- Return type:
- Parameters:
servent_id (str)
name (str)
entity_id (EntityID)
lower (float | None)
upper (float | None)
hysteresis (float)
default_state (bool | None)
entity_category (Literal['config', 'diagnostic'] | None)
disabled_by_default (bool)
app_name (str | None)
device_class (Literal['battery', 'battery_charging', 'carbon_monoxide', 'cold', 'connectivity', 'door', 'garage_door', 'gas', 'heat', 'light', 'lock', 'moisture', 'motion', 'moving', 'occupancy', 'opening', 'plug', 'power', 'presence', 'problem', 'running', 'safety', 'smoke', 'sound', 'tamper', 'update', 'vibration', 'window'] | None)
creation_config (ExtraConfig | None)
- async create_binary_sensor(servent_id, name, *, default_state=None, fixed_attributes=None, entity_category=None, disabled_by_default=False, app_name=None, device_class=None, creation_config=None)[source]¶
- Return type:
- Parameters:
servent_id (str)
name (str)
default_state (bool | None)
entity_category (Literal['config', 'diagnostic'] | None)
disabled_by_default (bool)
app_name (str | None)
device_class (Literal['battery', 'battery_charging', 'carbon_monoxide', 'cold', 'connectivity', 'door', 'garage_door', 'gas', 'heat', 'light', 'lock', 'moisture', 'motion', 'moving', 'occupancy', 'opening', 'plug', 'power', 'presence', 'problem', 'running', 'safety', 'smoke', 'sound', 'tamper', 'update', 'vibration', 'window'] | None)
creation_config (ExtraConfig | None)
- async create_number(servent_id, name, mode, *, default_state=None, fixed_attributes=None, entity_category=None, disabled_by_default=False, app_name=None, device_class=None, unit_of_measurement=None, min_value=None, max_value=None, step=None, creation_config=None)[source]¶
- Return type:
- Parameters:
servent_id (str)
name (str)
mode (Literal['auto', 'box', 'slider'])
default_state (float | None)
entity_category (Literal['config', 'diagnostic'] | None)
disabled_by_default (bool)
app_name (str | None)
device_class (Literal['absolute_humidity', 'apparent_power', 'aqi', 'area', 'atmospheric_pressure', 'battery', 'blood_glucose_concentration', 'carbon_monoxide', 'carbon_dioxide', 'conductivity', 'current', 'data_rate', 'data_size', 'distance', 'duration', 'energy', 'energy_distance', 'energy_storage', 'frequency', 'gas', 'humidity', 'illuminance', 'irradiance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'ph', 'pm1', 'pm10', 'pm25', 'pm4', 'power_factor', 'power', 'precipitation', 'precipitation_intensity', 'pressure', 'reactive_energy', 'reactive_power', 'signal_strength', 'sound_pressure', 'speed', 'sulphur_dioxide', 'temperature', 'temperature_delta', 'volatile_organic_compounds', 'volatile_organic_compounds_parts', 'voltage', 'volume', 'volume_storage', 'volume_flow_rate', 'water', 'weight', 'wind_direction', 'wind_speed'] | None)
unit_of_measurement (str | None)
min_value (float | None)
max_value (float | None)
step (float | None)
creation_config (ExtraConfig | None)
- async create_select(servent_id, name, options, *, default_state=None, fixed_attributes=None, entity_category=None, disabled_by_default=False, app_name=None, creation_config=None)[source]¶
- Return type:
- Parameters:
- async create_switch(servent_id, name, *, default_state=None, fixed_attributes=None, entity_category=None, disabled_by_default=False, app_name=None, device_class=None, creation_config=None)[source]¶
- async listen_button_press(callback, button_name, event_name_to_fire, *, event_data=None, device_class=None, entity_category=None, disabled_by_default=False, creation_config=None)[source]¶
- Return type:
- Parameters:
callback (EventListenerCallbackFull | EventListenerCallbackWithEventName | EventListenerCallbackWithEventData | Callable[[], None | Awaitable[None]])
button_name (str)
event_name_to_fire (str)
device_class (Literal['identify', 'restart', 'update'] | None)
entity_category (Literal['config', 'diagnostic'] | None)
disabled_by_default (bool)
creation_config (ExtraConfig | None)
Logger Plugin¶
Logging functionality scoped to each app.
- class domovoy.plugins.logger.LogLevels(*values)[source]¶
Bases:
Enum- CRITICAL = 50¶
- ERROR = 40¶
- WARNING = 30¶
- INFO = 20¶
- DEBUG = 10¶
- NOTSET = 0¶
- class domovoy.plugins.logger.LoggerCallbackRegistration(id, callback, minimum_log_level)[source]¶
Bases:
object
- class domovoy.plugins.logger.LoggerPlugin(name, wrapper)[source]¶
Bases:
AppPlugin- Parameters:
name (str)
wrapper (AppWrapper)
Meta Plugin¶
App metadata and lifecycle control.
Time Plugin¶
Time utilities for timezone-aware operations.
Utils Plugin¶
General utility functions.
- class domovoy.plugins.utils.UtilsPlugin(name, wrapper)[source]¶
Bases:
AppPlugin- Parameters:
name (str)
wrapper (AppWrapper)