Sentence trigger - #869
Conversation
|
Nice implementation! I still need more time for a full review. My first thought is to pass slots as named function arguments. That would be much more convenient. #From:
@sentence_trigger("turn on {name} in the {area}")
def voice_on(sentence, slots):
service.call("light", "turn_on", entity_id=f"light.{slots['name']}")
return f"Turned on {slots['name']} in the {slots['area']}"
#To:
@sentence_trigger("turn on {name} in the {area}")
def voice_on(sentence, name, area):
service.call("light", "turn_on", entity_id=f"light.{name}")
return f"Turned on {name} in the {area}"
Any objections? Edit: In my head, the legacy decorators and the new DM are already decoupled. I will try to speed up the work on removing the old subsystem. Alternatively, I can make a PR where DM is not tied to |
|
We keep doing things simultaneously! I just came to the same conclusion. So I think the options are,
@sentence_trigger("turn on {name} in the {area}")
def voice_on(sentence, name): # missing area!
service.call("light", "turn_on", entity_id=f"light.{name}")
return f"Turned on {name}"If all slots are included, this would work fine with the current
I definitely prefer either 2 or 3 as the long term solution, but am open to either option. |
|
I have a few spare tokens, and there can be no such thing as an unneeded review, so here's what Opus said: Reviewed at This is clean work, and the test file covers a lot: validators, apostrophes, positional and Six points below. 1. An exception or a cancellation makes the caller wait for the whole timeout
Without them, the future stays pending in three reachable cases:
In each case Your own test shows the cost: 2.
|
This is the first of two PRs for integrating pyscript with HA assist pipelines. It ties into the "exact matches" portion of the default HA assist pipeline. Should close #672.
This PR adds in
sentence_triggerthat (should) work near identically to the built-in sentence trigger. This includes return values being spoken, wildcards using {}, one of the following using (a|b|c), and optional words in []. I've been using this for ~week now and it's been working fairly flawless on basic cases.Let me know if there's anything that needs tweaking and as always I recommend giving it a shot first before merging. Next I hope to play with a
@intentdecorator that would register a method as an intent/tool for agents to call, similar to this integration.(Also shoutout to @dmamelin, the new decorator registry made this a breeze!)