Skip to content
26 June 2026

How to Handle Offline Devices and Expired Credentials in Home Assistant

Unlock the secrets to effortless integration recovery in Home Assistant. Learn how to manage offline devices and expired credentials with ease.

How to Handle Offline Devices and Expired Credentials in Home Assistant

In the world of smart home automation, ensuring that your Home Assistant integrations remain robust and resilient is paramount. There are instances when your integration might fail to set up due to various reasons, such as devices being offline or credentials expiring. Understanding how to handle these scenarios is crucial for maintaining a seamless smart home experience.

This guide will walk you through the best practices for managing offline devices and services, as well as handling expired credentials, ensuring that your Home Assistant setup remains reliable and user-friendly.

Managing Offline Devices and Services

When dealing with offline devices or services, it’s essential to implement strategies that allow your integrations to recover automatically. For integrations using async_setup_entry raising the ConfigEntryNotReady exception in the integration’s __init__.py file is the key. This approach ensures that Home Assistant will automatically retry the setup once the device or service comes back online.

For example, consider a scenario where your device times out while connecting. By raising the ConfigEntryNotReady exception with a descriptive message, you enable Home Assistant to log the issue and retry the setup later. This method avoids the need for manual intervention, providing a more user-friendly experience.

If your integration supports discovery, Home Assistant will automatically retry the setup as soon as the device or service is rediscovered. This feature adds an extra layer of reliability to your smart home setup.

Logging Retry Attempts

When raising the ConfigEntryNotReady exception, it’s important to pass an error message as the first argument. Home Assistant will log this message at the debug level, making it easier to track and resolve issues. The error message will also be displayed on the integrations page, providing users with clear feedback.

For integrations using async_setup_platform raising the PlatformNotReady exception serves a similar purpose. Home Assistant will log the initial retry attempt with a warning level and subsequent retries at the debug level. This approach ensures that users are informed about the issue without being overwhelmed by repetitive log entries.

Handling Expired Credentials

Expired credentials can disrupt the functionality of your integrations. To address this, raising the ConfigEntryAuthFailed exception is the recommended approach. This action prompts Home Assistant to put the config entry in a failure state and initiate a reauthentication flow.

The ConfigEntryAuthFailed exception must be raised from async_setup_entry in the __init__.py file or from the DataUpdateCoordinator to be effective. If your integration does not use a DataUpdateCoordinator you can use entry.async_start_reauth as an alternative to start the reauthentication flow.

During the reauthentication flow, context variables such as sourceentry_id and unique_id are available in the async_step_reauth step. These variables help streamline the reauthentication process, ensuring a smooth user experience.

For instance, if your device’s credentials expire, raising the ConfigEntryAuthFailed exception with a descriptive message will trigger the reauthentication flow. This approach ensures that users can quickly resolve credential issues without extensive manual intervention.

By implementing these best practices, you can enhance the reliability and user-friendliness of your Home Assistant integrations. Whether dealing with offline devices or expired credentials, these strategies will help you maintain a seamless smart home experience.

Author

Thomas Hughes

Thomas Hughes, a property and real estate journalist, reports on the housing market, second-home purchases and mortgage trends, guiding buyers and sellers through property decisions.