ConfigEntry Class
TheConfigEntry class represents a single configuration entry for an integration.
Initialization
The integration domain
User-friendly title for this config entry
Configuration data
Source of the configuration (user, discovery, import, etc.)
Optional configuration that can be modified by the user
Unique identifier for this configuration entry
Entry ID (auto-generated ULID if not provided)
Configuration version number
Minor version number
Key Attributes
Unique ID for this config entry (ULID format)
Integration domain this entry belongs to
User-friendly title
Read-only configuration data. Use
async_update_entry to modify.Read-only options. Use
async_update_entry to modify.Runtime data that can be set by the integration during setup. This data is not persisted.
Current state of the config entry (LOADED, NOT_LOADED, SETUP_ERROR, etc.)
Unique identifier for this entry
Source that created this entry (user, discovery, import, reauth, etc.)
Major version number
Minor version number
Reason the entry is disabled, if any
Whether the integration supports unloading
Whether the integration supports device removal
Whether the integration supports options flow
Whether the integration supports reconfiguration
Lifecycle Methods
async_setup(hass, *, integration=None)
Set up the config entry.Home Assistant instance
Integration object (loaded automatically if not provided)
async_unload(hass, *, integration=None)
Unload the config entry.Home Assistant instance
Integration object
True if unload was successful
async_remove(hass)
Invoke the remove callback on the component.Task Management
async_create_task(hass, target, name=None, eager_start=True)
Create a task tied to the config entry lifecycle.Home Assistant instance
Coroutine to execute
Task name
Whether to start eagerly
async_create_background_task(hass, target, name, eager_start=True)
Create a background task that’s automatically cancelled when the entry is unloaded.Listeners
add_update_listener(listener)
Listen for when the entry is updated.Async function called when entry is updated
Function to remove the listener
async_on_unload(func)
Add a function to call when config entry is unloaded.Reauth
async_start_reauth(hass, context=None, data=None)
Start a reauth flow for this entry.Home Assistant instance
Additional context for the flow
Additional data for the flow
ConfigEntryState Enum
States a config entry can be in.The config entry has been set up successfully
The config entry has not been loaded
There was an error while trying to set up this config entry
The config entry was not ready to be set up yet, but might be later
The config entry is currently setting up
There was an error while trying to migrate the config entry
An error occurred when trying to unload the entry
The config entry is being unloaded
Source Constants
Common sources for config entries:ConfigEntries Manager
TheConfigEntries manager (accessible via hass.config_entries) provides methods to manage all config entries.
async_get_entry(entry_id)
Get a config entry by ID.async_entries(domain=None)
Get all config entries, optionally filtered by domain.async_reload(entry_id)
Reload a config entry.async_update_entry(entry, *, data=None, options=None, title=None, unique_id=None)
Update a config entry.Config entry to update
New data (replaces existing data)
New options (replaces existing options)
New title
New unique_id
Integration Setup
Integrations implement config entry support by providing specific functions in their__init__.py:
async_setup_entry(hass, entry)
Set up the integration from a config entry.Home Assistant instance
Config entry to set up
True if setup was successful
async_unload_entry(hass, entry)
Unload a config entry.async_migrate_entry(hass, entry)
Migrate an old config entry to a new version.Best Practices
Store Runtime Data
Useentry.runtime_data to store runtime objects: