this post was submitted on 20 Mar 2024
16 points (100.0% liked)

homeassistant

12051 readers
56 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
 

Howdy.

I have the following helpers:

  • input_text.countdown_date_01_name
  • input_datetime.countdown_date_01_date,
  • input_text.countdown_date_02_name
  • input_datetime.countdown_date_02_date
  • I want to add a couple more if I can get this to work

I want to be able to speak "how many days until X", where X is the value of either input_text.countdown_date_01_name or input_text.countdown_date_02_name, and have Home Assistant speak the response "there are Y days until X", where X is the value of either input_text.countdown_date_01_name or input_text.countdown_date_02_name, whichever was spoken.

I know how to determine the number of days until the date that is the value of input_datetime.countdown_date_01_date or input_datetime.countdown_date_02_date. But so far I've been unable to figure out how to configure the sentence/intent so that HA knows which one to retrieve the value of.

In config/conversations.yaml I have:

intents:
  HowManyDaysUntil:
    - "how many days until {countdownname}"

In config/intents/sentences/en/_cmmon.yaml I have:

lists:
  countdownname:
    values:
      - '{{ states("input_text.countdown_date_01_name") }}'
      - '{{ states("input_text.countdown_date_02_name") }}'

In config/intent_scripts.yaml I have:

HowManyDaysUntil:
  action:
    service: automation.trigger
    data:
      entity_id: automation.how_many_days_until_countdown01

(this automation currently is hardocded to calculate and speak the days until input_datetime.countdown_date_01_date)

The values of my helpers are currently:

  • input_text.countdown_date_01_name = "vacation"
  • input_datetime.countdown_date_01_date = "6/1/2024'

When I speak "how many days until vacation" I get Unexpected error during intent recognition.

I'd appreciate your help with this!

top 3 comments
sorted by: hot top controversial new old
[–] paf@jlai.lu 2 points 7 months ago* (last edited 7 months ago) (1 children)

Not 100℅ sure...

Your intent script might need to be a bit different using

speech:
   text:

As shown below https://www.home-assistant.io/integrations/intent_script/

   intent_script:
    CustomOutsideHumidity:
      speech:
       text: "It is currently {{ states('sensor.outside_humidity') }} percent humidity outside."

Aldo have a look at https://developers.home-assistant.io/docs/voice/intent-recognition/template-sentence-syntax/ for the common.yaml

[–] mike_wooskey@lemmy.d.thewooskeys.com 2 points 7 months ago (1 children)

Thanks for the references, but at least one example from https://www.home-assistant.io/integrations/intent_script/ seems to be wrong/outdated.

From that page:

Local lists

Sometimes you don't need a slot list available for all intents and sentences, so you can define one locally, making it usable only in the context of the intent data (like a collection of sentences) where it was defined. For example:

language: en
intents:
  AddListItem:
    data:
      - sentences:
          - add {item} to [my] shopping list
        lists:
          item:
            wildcard: true

This is the code in my conversations.yaml:

intents:
  HowManyDaysUntil:
    data:
      - sentences:
          - how many days until {countdownname}
        lists:
          countdownname:
            - "this"
            - "that"

Here are the only difference I see between my code and the example above:

  • I don't have language: en (but when I add it, I get Invalid config for 'conversation' at conversations.yaml, line 1: 'language' is an invalid option for 'conversation', check: conversation->language)
  • The example uses a wildcard and I'm using strings (but I'm following their other examples to have a list of strings)

However, this yaml gets Invalid config for 'conversation' at conversations.yaml, line 9: value should be a string 'conversation->intents->HowManyDaysUntil->0', got None

Perhaps I can't have intents in conversations.yaml? Or maybe not lists? I started this project by editing config/intents/sentences/en/_cmmon.yaml but that's a bad idea because an update would wipe my customizations. What's the appropriate place for me to add custom sentences/intents/responses/lists?

[–] paf@jlai.lu 1 points 7 months ago

i'm willing to try to help you but to be honest, it is far from my limited knowledge... and i'm also not english native so i do sometimes struggle to understand some specifc docs...

That being said, looks like exemple given at https://developers.home-assistant.io/docs/voice/intent-recognition/template-sentence-syntax/ isn't inside _common.yaml

# Example light_HassTurnOn.yaml
language: "en"

also i just realised that this is developer document which could explain why _common.yaml modifications would be wiped out after an update.

I just had a look to the non developer doc and it suggest intent_script is to be added to configuration.yaml and intent to custom_sentences/<language> as shown here https://www.home-assistant.io/integrations/conversation/

# Example configuration.yaml entry
intent_script:
# Example temperature.yaml entry
language: "en"
intents: