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

Commit

Permalink
Use ConversationAgentSelector (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
m50 authored Feb 28, 2024
1 parent 94616f2 commit ee05653
Showing 1 changed file with 4 additions and 23 deletions.
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()),
};

0 comments on commit ee05653

Please sign in to comment.