Home Assistant Core

2026.4.2 · active · verified Sun Apr 12

Home Assistant Core is the open-source home automation platform's Python foundation, providing a robust, event-driven framework for observing states, controlling devices, and automating tasks. It is actively developed with monthly releases, currently at version 2026.4.2.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically start and interact with a basic Home Assistant Core instance, primarily for testing or embedding purposes. For integration development, you would typically use the `python3 -m script.scaffold integration` command within a development environment to generate a boilerplate custom component structure, then implement your logic in `__init__.py`, `config_flow.py`, and entity platform files.

import asyncio
from homeassistant.core import HomeAssistant, CoreState

async def run_hass_instance():
    hass = HomeAssistant(".homeassistant") # Use a temporary config directory
    await hass.async_start()
    print(f"Home Assistant started. State: {hass.state}")

    # Example: Set a state (e.g., for a custom sensor)
    hass.states.async_set("test.hello_world", "Hello from Python!")
    print(f"State of test.hello_world: {hass.states.get('test.hello_world').state}")

    # Keep running for a short period or until manually stopped
    await asyncio.sleep(5)

    await hass.async_stop()
    print("Home Assistant stopped.")

if __name__ == "__main__":
    # Note: Running Home Assistant Core programmatically like this is mostly for testing or specific advanced scenarios.
    # For typical development, you would create a custom component and run HA via its standard entrypoint.
    try:
        asyncio.run(run_hass_instance())
    except KeyboardInterrupt:
        print("Operation interrupted by user.")

view raw JSON →