this post was submitted on 18 Apr 2024
12 points (100.0% liked)

homeassistant

11833 readers
9 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 1 year ago
MODERATORS
 

I have input_text.event_1 where the value is currently "birthday", input_text.event_2 where the value is currently "christmas", input_date.event_1 where the value is currently "1/1/2000", and input_date.event_2 where the value is currently "12/25/2024". How do I configure voice assistant to recognize a phrase like "what's the date of birthday" and returns "1/1/2000"?

I'm guessing there's some combination of templating and "lists", but there are too many variables for me to continue guessing: conversations, intents, sentences, slots, lists, wildcards, yaml files...

I've tried variations of this in multiple files:

language: "en"
intents:
  WhatsTheDateOf:
    - "what's the date of {eventname}"
    data:
      - sentences:
          - "what's the date of {eventname}"
lists:
  eventname:
    wildcard:
      true
      - "{{ states('input_text.event_1') }}"
      - "{{ states('input_text.event_2') }}"

Should it be in conversations.yaml, intent_scripts.yaml, or a file in custom_sentences/en? Or does the "lists" go in one file and "intents" go in another? In the intent, do I need to define my sentence twice?

I'd appreciate any help. I feel like once I see the yaml of a way that works, I'll be able to examine it and understand how to make derivations work in the future.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 4 months ago* (last edited 4 months ago) (2 children)

I did just check to see if you can pass along wildcards in an automation, which you can! I used this automation:

alias: sentence test
description:
trigger:
  - platform: conversation
    command:
      - When is [my] {date}
condition: []
action:
  - set_conversation_response: curses, that damnable {{ trigger.slots.game }}
    enabled: false
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ ''birthday'' in trigger.slots.date }}'
        sequence:
          - set_conversation_response: >-
              curses, that damnable {{ trigger.slots.date }}! It completely
              slipped my mind
      - conditions:
          - condition: template
            value_template: '{{ ''christmas'' in trigger.slots.date }}'
        sequence:
          - set_conversation_response: sir you know when {{ trigger.slots.date }} is!

This should give you a framework to build off of. It looks like when you don't define a list of slots in an intent it just passes the wildcard along in a slot.

[–] [email protected] 1 points 4 months ago

I'm embarassed but very pleased that your example also taught me about set_conversation_response! I had been using tts.speak, which meant I had to define a specific media player, which wasn't always I wanted to do. This is great!

[–] [email protected] 1 points 4 months ago (1 children)

That is HUGE! Thank you, @[email protected]! This makes customizing conversations from automations so much more powerful and flexible!

[–] [email protected] 1 points 4 months ago

No problem! I've been puttering around trying to figure this out and this post gave me the push I needed lol