Voice asks which device you mean when two fit the name - #22
Merged
Merged
Conversation
When the action is clear and the entity answer is split between two exposed devices, the agent asks "Do you mean A or B?" and keeps the microphone open. The reply gets one small question about those two devices, and the first command then runs on the one it picked. A reply that picks neither is handled as a new command. The question lasts as long as the chat session.
# Conflicts: # tests/test_conversation.py
# Conflicts: # custom_components/jev/conversation.py
On a development instance with two lights both called "Lamp", "turn on the lamp" came back as one of them at 1.00, every time. The entity answer never split, so the ask-back never asked, and the agent acted on a guess that looked sure. The candidates now come from the exposed names of the chosen device's kind. The whole name said beats a name that only shares a word with the command, so "the lamp" is Lamp beside a Desk lamp, and "the desk lamp" is the Desk lamp. Two names that fit equally well get the question. More than two fall back. A room the model is sure of narrows the list first, so "the lamp in the office" acts. When no name fits the words at all, the model's answer stands as before. A reply that picks a device reads the command again without the check, so it does not ask the same question twice.
Home Assistant's own agent prefers the satellite's area when a name fits devices in several rooms. Jev asked instead. It now reads the satellite entity's area, then its device's area, the same lookup, and asks only when that room does not hold exactly one of the devices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the action answer is sure but the entity answer is split between two exposed devices, the voice agent now asks "Do you mean A or B?" and does not fall back. The result has
continue_conversation=True, so a satellite opens the microphone for the reply.How it decides to ask (
interpret._two_that_fit):ASK_BACK_FLOOR(0.2) of the entity answer. A third device above the floor means that one question does not settle it, so the agent falls back as before.0.2 is not measured on a real instance. The comment says so.
How the reply is handled:
CONVERSATION_TIMEOUT(5 minutes, Home Assistant's chat session lifetime).{"command": ..., "reply": ...}. It goes through the same budget check, reservation and error handling as a command.interpretruns again on the first sentence, so a brightness that the sentence named still comes from the text.The handler is split into
_ask(the budget check and the call),_trace,_act(everything after interpret, unchanged),_ask_whichand_resolve. The new linewhich_deviceis in strings.json and all 13 translations.Tests: 12 new tests in test_conversation.py. They cover the question, the pick, neither, an unsure reply, another conversation, expiry, a third device, same name and same room, same name and two rooms, a Dutch pipeline, and a reply past the budget.
Changes after live testing on a development instance:
actionkey.new_request: does it ask for something of its own? Pure picks scored 0.08 to 0.26, new commands 0.91 to 0.97. At 0.5 or more the reply is handled as a new command, so "never mind, turn off the lamp in the bedroom" turns that lamp off.Local gate: ruff, ruff format, mypy --strict, pytest (433 passed, 12 skipped), config_flow 100%, mkdocs --strict, hassfest. EXIT 0.
Part 3 of the 1.16 work. Stacked on #21.