mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Deprecate conversation agents that are not entities (#189183)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
86187295ec
commit
f93f45674e
@@ -11,7 +11,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import MATCH_ALL
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryError
|
||||
from homeassistant.helpers import config_validation as cv, intent
|
||||
from homeassistant.helpers import config_validation as cv, frame, intent
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
@@ -108,6 +108,15 @@ def async_set_agent(
|
||||
agent: AbstractConversationAgent,
|
||||
) -> None:
|
||||
"""Set the agent to handle the conversations."""
|
||||
if not isinstance(agent, ConversationEntity):
|
||||
frame.report_usage(
|
||||
"sets a conversation agent that is not a conversation entity. Convert "
|
||||
"the conversation platform to use ConversationEntity",
|
||||
breaks_in_ha_version="2027.6.0",
|
||||
# Test agents use config entries of domains that are not loaded
|
||||
core_behavior=frame.ReportBehavior.LOG,
|
||||
integration_domain=config_entry.domain,
|
||||
)
|
||||
get_agent_manager(hass).async_set_agent(config_entry.entry_id, agent)
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,13 @@ from unittest.mock import patch
|
||||
|
||||
import probatio
|
||||
import pytest
|
||||
from pytest_homeassistant.common import MockUser, async_mock_service
|
||||
from pytest_homeassistant.common import (
|
||||
MockConfigEntry,
|
||||
MockModule,
|
||||
MockUser,
|
||||
async_mock_service,
|
||||
mock_integration,
|
||||
)
|
||||
from pytest_homeassistant.typing import ClientSessionGenerator
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
@@ -151,6 +157,24 @@ async def test_custom_agent(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_components")
|
||||
async def test_set_agent_not_entity_deprecated(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test that setting an agent that is not an entity is deprecated."""
|
||||
mock_integration(hass, MockModule("legacy_agent"))
|
||||
entry = MockConfigEntry(domain="legacy_agent")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
conversation.async_set_agent(hass, entry, MockAgent(entry.entry_id, ["en"]))
|
||||
|
||||
assert (
|
||||
"Detected that integration 'legacy_agent' sets a conversation agent that "
|
||||
"is not a conversation entity. Convert the conversation platform to use "
|
||||
"ConversationEntity. This will stop working in Home Assistant 2027.6.0"
|
||||
) in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_components")
|
||||
async def test_reload(hass: HomeAssistant) -> None:
|
||||
"""Test calling the reload service."""
|
||||
|
||||
Reference in New Issue
Block a user