Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Use ConversationAgentSelector #3

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions custom_components/fallback_conversation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from homeassistant.data_entry_flow import FlowResult
from homeassistant.components.conversation import _get_agent_manager
from homeassistant.helpers.selector import (
ConversationAgentSelector,
ConversationAgentSelectorConfig,
SelectSelector,
SelectSelectorConfig,
SelectOptionDict,
Expand Down Expand Up @@ -103,11 +105,6 @@ async def async_step_init(

async def fallback_config_option_schema(self, options: dict) -> dict:
"""Return a schema for Fallback options."""

agent_manager = _get_agent_manager(async_get_hass())
agents = agent_manager.async_get_agent_info()


return {
vol.Required(
CONF_DEBUG_LEVEL,
Expand All @@ -127,25 +124,9 @@ async def fallback_config_option_schema(self, options: dict) -> dict:
CONF_PRIMARY_AGENT,
description={"suggested_value": options.get(CONF_PRIMARY_AGENT, "homeassistant")},
default="homeassistant",
): SelectSelector(
SelectSelectorConfig(
options = [
SelectOptionDict(value=agent.id, label=agent.name)
for agent in agents if agent.name != self._options[CONF_NAME]
],
mode=SelectSelectorMode.DROPDOWN,
)
),
): ConversationAgentSelector(ConversationAgentSelectorConfig()),
vol.Required(
CONF_FALLBACK_AGENT,
description={"suggested_value": options.get(CONF_FALLBACK_AGENT, "")},
): SelectSelector(
SelectSelectorConfig(
options = [
SelectOptionDict(value=agent.id, label=agent.name)
for agent in agents if agent.name != self._options[CONF_NAME]
],
mode=SelectSelectorMode.DROPDOWN,
)
),
): ConversationAgentSelector(ConversationAgentSelectorConfig()),
};
Loading