TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/home-assistant/core/llms.txt
Use this file to discover all available pages before exploring further.
homeassistant.core module contains the fundamental classes that power Home Assistant.
HomeAssistant Class
TheHomeAssistant class is the root object of the Home Assistant home automation system.
Initialization
Path to the configuration directory
Key Attributes
Dictionary that any component can store data on. This is the primary way to share data between components.
The event bus for firing and listening to events.
The service registry for registering and calling services.
The state machine for tracking entity states.
Configuration object containing Home Assistant settings.
Current state of Home Assistant (NOT_RUNNING, STARTING, RUNNING, STOPPING, STOPPED).
The asyncio event loop.
Methods
async_start()
Finalize startup from inside the event loop.async_stop(exit_code: int = 0, *, force: bool = False)
Stop Home Assistant and shut down all threads.Exit code to return
Force stop regardless of current state
async_create_task(target, name=None, eager_start=True)
Create a task from within the event loop.Coroutine to execute
Name for the task (useful for debugging)
Whether to start the task eagerly
The created task
async_create_background_task(target, name, eager_start=True)
Create a background task that won’t block startup or shutdown.Coroutine to execute
Name for the task
Whether to start the task eagerly
async_add_executor_job(target, *args)
Add an executor job from within the event loop.Function to execute in the executor
Arguments to pass to the function
State Class
Represents the state of an entity.Initialization
The entity ID (format: domain.object_id)
The state value
Additional attributes for the state
When the state was last changed
When the state or attributes were last updated
Context in which the state was created
Attributes
The entity ID
The state value
Read-only dictionary of attributes
Domain portion of the entity ID
Object ID portion of the entity ID
When the state was last changed
When the state or attributes were last updated
Last time the state was reported
Context object containing user_id, parent_id, and id
Methods
as_dict()
Return a read-only dictionary representation of the state.Event Class
Represents an event within the event bus.Initialization
Type of the event
Event data
Origin of the event (local or remote)
Context in which the event was fired
Attributes
Type of the event
Event data dictionary
Origin of the event (local or remote)
When the event was fired
Context object
ServiceCall Class
Represents a call to a service.Initialization
Home Assistant instance
Domain of the service
Name of the service
Service call data
Context for the service call
Whether to return a response
Attributes
Service domain
Service name
Service call data
Context object
Whether a response is expected
Context Class
Represents the context that triggered something.Initialization
ID of the user who triggered the action
ID of the parent context
Unique ID for this context (auto-generated if not provided)
Attributes
Unique context ID (ULID format)
User ID if triggered by a user
Parent context ID if this is a child context
Helper Functions
callback(func)
Decorator to mark a method as safe to call from within the event loop.async_get_hass()
Return the HomeAssistant instance from within the event loop.split_entity_id(entity_id: str)
Split a state entity ID into domain and object ID.Entity ID to split
Tuple of (domain, object_id)
valid_entity_id(entity_id: str)
Test if an entity ID is in a valid format.CoreState Enum
Represents the current state of Home Assistant.Home Assistant is not running
Home Assistant is starting up
Home Assistant is running
Home Assistant is stopping
Final write stage during shutdown
Home Assistant has stopped
EventOrigin Enum
Represents the origin of an event.Event originated locally
Event originated from a remote source