Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - static value for named group #2

Open
michaelblight opened this issue Aug 22, 2023 · 1 comment
Open

Feature request - static value for named group #2

michaelblight opened this issue Aug 22, 2023 · 1 comment

Comments

@michaelblight
Copy link

michaelblight commented Aug 22, 2023

I've been using this for a while now, and pretty happy! I have a new use case where the phrases are different but the actions are largely the same, related to going to bed and getting up in the morning. This is the current Yarvis config I have:

bedStatus:
  sentences:
    - i'm (?P<which>going) to bed
    - i'm going to (?P<which>sleep)
    - i'm (?P<which>awake)
    - i'm getting (?P<which>out) of bed

This works fine when HA hears correctly, but this seems to be a rare occurrence. Is there any possibility of passing hardcoded values for parameters? I'm thinking something along the lines of:

    - i'm (?P<which=going>going) to bed

Obviously this breaks the regex, so you would have to change the sentence to remove the "=going" part before passing to regex. This could be done by using sub() to replace <(?P<param>.*)=(?P<value>.*)> with \<\g<param>\>. Then if it matches, send the static value for the named group instead of whatever it captured.

My logic in suggesting this is HA's speech-to-text often mis-hears words. So "going" might be heard as "doing", "gone" or "gong" (among others). So then I could code my sentences as:

    - i'm (?P<which=going>going|doing|gone|gong) to bed

This way, even if it hears "gone" the intent script will receive "going". Without something like this I would need to deal with all the possible mis-hearings in the intent script as multiple sentences and different parameters.

@siemon-geeroms
Copy link
Owner

nice addition, I'm going to think about that, maybe we can even introduce a kind of fuzzy search that matches a sentence and return a match % if the result is above a certain threshold it activates that action. so this means that you don't have to provide a list with possible words

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants