feat: add intent= to ha_call_service for HA media intents (closes #899) - #921
feat: add intent= to ha_call_service for HA media intents (closes #899)#921Patch76 wants to merge 13 commits into
Conversation
…tant-ai#899) Routes to POST /api/intent/handle when intent= is set. Focused on media intents (HassMediaSearch, HassMediaPause) that have no direct service-call equivalent.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces support for Home Assistant intents within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for Home Assistant intents within the ha_call_service tool. It adds a call_intent method to the REST client and updates the tool logic to route requests to the intent handler when the new intent parameter is provided. To improve the implementation, the JSON parsing for intent data should be wrapped in a try...except block to return structured validation errors in accordance with the repository's error-handling guidelines. Furthermore, since domain and service are now optional, a validation check is needed to ensure they are present when an intent is not specified, preventing potential runtime errors during normal service routing.
…, improve validation message
…ing domain/service, string data)
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces intent handling to the ha_call_service tool, allowing users to trigger Home Assistant intents via the REST API. The changes include a new call_intent method in the REST client, updated tool logic to route requests based on the presence of an intent parameter, and comprehensive unit tests. I have provided feedback regarding the need for more specific exception handling to improve debuggability and consistency with repository standards.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for Home Assistant intents within the ha_call_service tool by adding a call_intent method to the REST client and implementing routing logic to handle intent-based requests. The changes include updated parameter validation, specialized error handling for intents, and a new suite of unit tests to verify the routing behavior. Feedback suggests refactoring the intent processing logic into a dedicated helper function to improve the maintainability and focus of the ha_call_service tool.
What does this PR do?
Extends
ha_call_servicewith an optionalintent=parameter that routes toPOST /api/intent/handleinstead of the standard service endpoint.This covers the remaining use cases from #899 that have no direct service-call
equivalent — specifically media intents (
HassMediaSearch,HassMediaPause,HassMediaUnpause) where the intent layer provides semantic resolution that plainservice calls don't offer.
What's already covered by existing tools (not in scope):
ha_eval_templateha_call_service+ha_search_entitiesha_call_servicewitharea_idNew usage:
When
intent=is set,domainandserviceare ignored. Requires theconversationintegration (enabled by default since HA 2023.2).Design note:
domain="intent"was rejected — custom integrations couldregister an
intentservice domain. Theintent=parameter avoids namespacecollision while keeping the feature in
ha_call_serviceper #899 direction.Closes #899
Type of change
Testing
uv run pytest)uv run ruff check)Checklist