Add devices to OpenRouter (#148888)

This commit is contained in:
Joost Lekkerkerker 2025-07-16 15:07:53 +02:00 committed by GitHub
parent 3e465da892
commit 412035b970
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,6 +16,7 @@ from homeassistant.const import CONF_LLM_HASS_API, CONF_MODEL, MATCH_ALL
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import intent
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import OpenRouterConfigEntry
@ -61,13 +62,20 @@ def _convert_content_to_chat_message(
class OpenRouterConversationEntity(conversation.ConversationEntity):
"""OpenRouter conversation agent."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, entry: OpenRouterConfigEntry, subentry: ConfigSubentry) -> None:
"""Initialize the agent."""
self.entry = entry
self.subentry = subentry
self.model = subentry.data[CONF_MODEL]
self._attr_name = subentry.title
self._attr_unique_id = subentry.subentry_id
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, subentry.subentry_id)},
name=subentry.title,
entry_type=DeviceEntryType.SERVICE,
)
@property
def supported_languages(self) -> list[str] | Literal["*"]: