> ## Documentation 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 Module

> Main entry point for Home Assistant Core

The `homeassistant` module is the main entry point for Home Assistant Core. It provides the foundational components for the home automation framework.

## Overview

Home Assistant is a home automation framework for observing the state of entities and reacting to changes. The core module provides:

* **Event System**: Fire and listen to events throughout the system
* **State Machine**: Track and manage entity states
* **Service Registry**: Register and call services
* **Config Entries**: Manage integration configurations
* **Integration Loader**: Load and manage integrations

## Core Components

The main components accessible through the homeassistant module:

### HomeAssistant Instance

The `HomeAssistant` class is the root object that coordinates all home automation functionality. See [Core APIs](/api/core) for details.

### Event Bus

The event bus (`EventBus`) allows components to fire and listen for events. Events are the primary way components communicate with each other.

### State Machine

The state machine (`StateMachine`) tracks the state of all entities in the system. It provides methods to get, set, and remove entity states.

### Service Registry

The service registry (`ServiceRegistry`) manages all available services that can be called by users or automations.

## Key Concepts

### Entities

Entities are the fundamental building blocks in Home Assistant. Each entity has:

* A unique entity ID (format: `domain.object_id`)
* A state (string value)
* Attributes (dictionary of additional data)
* A context (tracking who/what triggered changes)

### Events

Events are fired when something happens in Home Assistant. Common events include:

* `state_changed`: When an entity's state changes
* `service_registered`: When a new service is registered
* `homeassistant_start`: When Home Assistant starts
* `homeassistant_stop`: When Home Assistant stops

### Services

Services are callable actions that perform specific tasks. They are organized by domain and can accept parameters.

## Module Structure

```
homeassistant/
├── __init__.py          # Main module
├── core.py              # Core classes (HomeAssistant, State, Event, etc.)
├── config_entries.py    # Configuration entry management
├── loader.py            # Integration loading system
└── components/          # Built-in integrations
```

## Usage Example

```python theme={null}
from homeassistant.core import HomeAssistant, callback

# Get the HomeAssistant instance (in async context)
async def my_setup(hass: HomeAssistant):
    # Access the state machine
    state = hass.states.get("light.living_room")
    
    # Set a state
    hass.states.async_set(
        "sensor.my_sensor",
        "23.5",
        {"unit_of_measurement": "°C"}
    )
    
    # Listen for events
    @callback
    def handle_event(event):
        print(f"Event fired: {event.event_type}")
    
    hass.bus.async_listen("my_event", handle_event)
    
    # Call a service
    await hass.services.async_call(
        "light",
        "turn_on",
        {"entity_id": "light.living_room"}
    )
```

## Related Documentation

* [Core APIs](/api/core) - Detailed documentation of core classes
* [Config Entries](/api/config-entries) - Configuration entry management
* [Integration Loader](/api/loader) - Integration loading system

## Version

The current version is available via:

```python theme={null}
from homeassistant.const import __version__
print(__version__)
```
