ConfigEntry Class
TheConfigEntry class represents a single configuration entry for an integration.
Initialization
str
required
The integration domain
str
required
User-friendly title for this config entry
Mapping[str, Any]
required
Configuration data
str
required
Source of the configuration (user, discovery, import, etc.)
Mapping[str, Any]
Optional configuration that can be modified by the user
str
Unique identifier for this configuration entry
str
Entry ID (auto-generated ULID if not provided)
int
default:"1"
Configuration version number
int
default:"1"
Minor version number
Key Attributes
str
Unique ID for this config entry (ULID format)
str
Integration domain this entry belongs to
str
User-friendly title
MappingProxyType[str, Any]
Read-only configuration data. Use
async_update_entry to modify.MappingProxyType[str, Any]
Read-only options. Use
async_update_entry to modify.Any
Runtime data that can be set by the integration during setup. This data is not persisted.
ConfigEntryState
Current state of the config entry (LOADED, NOT_LOADED, SETUP_ERROR, etc.)
str | None
Unique identifier for this entry
str
Source that created this entry (user, discovery, import, reauth, etc.)
int
Major version number
int
Minor version number
ConfigEntryDisabler | None
Reason the entry is disabled, if any
bool | None
Whether the integration supports unloading
bool | None
Whether the integration supports device removal
bool
Whether the integration supports options flow
bool
Whether the integration supports reconfiguration
Lifecycle Methods
async_setup(hass, *, integration=None)
Set up the config entry.HomeAssistant
required
Home Assistant instance
Integration
Integration object (loaded automatically if not provided)
async_unload(hass, *, integration=None)
Unload the config entry.HomeAssistant
required
Home Assistant instance
Integration
Integration object
bool
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.HomeAssistant
required
Home Assistant instance
Coroutine
required
Coroutine to execute
str
Task name
bool
default:"True"
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.UpdateListenerType
required
Async function called when entry is updated
CALLBACK_TYPE
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.HomeAssistant
required
Home Assistant instance
ConfigFlowContext
Additional context for the flow
dict[str, Any]
Additional data for the flow
ConfigEntryState Enum
States a config entry can be in.str
The config entry has been set up successfully
str
The config entry has not been loaded
str
There was an error while trying to set up this config entry
str
The config entry was not ready to be set up yet, but might be later
str
The config entry is currently setting up
str
There was an error while trying to migrate the config entry
str
An error occurred when trying to unload the entry
str
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.ConfigEntry
required
Config entry to update
Mapping[str, Any]
New data (replaces existing data)
Mapping[str, Any]
New options (replaces existing options)
str
New title
str
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.HomeAssistant
required
Home Assistant instance
ConfigEntry
required
Config entry to set up
bool
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: