I have seen many times people saying they wish they could control their devices with the built in conversation agent in Home Assistant, but then forward other requests to ChatGPT (for example), and after not seeing anyone else do it, I decided to dip my toes into writing my first ever Home Assistant custom component: Fallback Conversation Agent.
Here’s an example of it in use (with some debugging enabled to make it clear):
Features
This custom component allows you to use two conversation agents, falling back if your primary agent fails to handle the intent.
An example use case of this is to use the built-in Home Assistant conversation agent to handle manipulating devices, but then fallback to using ChatGPT for example to handle general questions such as the capital of a country or measurement conversions.
The options provide 3 debug levels:
- No Debug: This silently handles fallback, and pipes back the raw response to you.
- Low Debug: This will add information such as what agent is responding to the response. This way you can determine if fallback is working as you expect.
- Verbose Debug: Will provide you with more information, including the error of the previous response.
For now, this only allows a primary and a fallback conversation agent, but I do plan on adding the ability to have a list so you can specify as many as you’d like, but I figured I’d let people have access to it in the meantime, and get some feedback.
Installation
- Install via registering as a custom repository of HACS or by copying the
fallback_conversation
folder into<config>/custom_components
. - Restart Home Assistant.
- Go to Settings > Devices & Services.
- In the bottom right corner, select the Add Integration button.
- Set a name and your preferred debug level.
- Click on Fallback Conversation Agent and select Configure on your created agent.
- Set the primary and fallback conversations agents from the list.
- Go to Settings > Voice Assistants.
- Click to edit Assistant (named “Home Assistant” by default).
- Select the name of your Fallback Conversation Agent from the “Conversation agent” tab