Add assist_satellite LLM tools platform (#175655)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Michael Hansen <mike@rhasspy.org>
This commit is contained in:
Paulus Schoutsen
2026-07-08 15:47:19 +02:00
committed by GitHub
parent 1020c06e52
commit 0232f4042b
2 changed files with 58 additions and 0 deletions
@@ -0,0 +1,24 @@
"""LLM tools for the assist_satellite integration."""
from homeassistant.components.llm import LLMTools
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import intent
from homeassistant.helpers.llm import LLM_API_ASSIST, IntentTool, LLMContext, Tool
@callback
def async_get_tools(
hass: HomeAssistant, llm_context: LLMContext, api_id: str
) -> LLMTools | None:
"""Return the broadcast LLM tool."""
if api_id != LLM_API_ASSIST:
return None
# assist_satellite registers the broadcast intent when it is set up, and
# this platform is only queried once that has happened.
tools: list[Tool] = [
IntentTool(handler.intent_type, handler)
for handler in intent.async_get(hass)
if handler.intent_type == intent.INTENT_BROADCAST
]
return LLMTools(tools=tools)
@@ -0,0 +1,34 @@
"""Tests for the assist_satellite LLM tools platform."""
import pytest
from homeassistant.components import llm as llm_component
from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import llm
from homeassistant.setup import async_setup_component
@pytest.fixture(autouse=True)
async def init_integrations(hass: HomeAssistant) -> None:
"""Set up the integrations; assist_satellite registers the broadcast intent."""
assert await async_setup_component(hass, "homeassistant", {})
assert await async_setup_component(hass, "intent", {})
assert await async_setup_component(hass, "llm", {})
assert await async_setup_component(hass, "assist_satellite", {})
def _llm_context() -> llm.LLMContext:
"""Return an LLM context for the conversation assistant."""
return llm.LLMContext(
platform="test_platform",
context=Context(),
language="*",
assistant="conversation",
device_id=None,
)
async def test_broadcast_tool_offered(hass: HomeAssistant) -> None:
"""Test the broadcast intent is exposed as an LLM tool."""
result = await llm_component.async_get_tools(hass, _llm_context(), "assist")
assert "HassBroadcast" in [tool.name for tool in result.tools]