• 21 Posts
  • 72 Comments
Joined 11 months ago
cake
Cake day: July 31st, 2023

help-circle





















  • 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?




  • From what I understand, a timer’s duration is the amount of time the timer was set to run for when it was started - the total time, not the time remaining.

    If you’re wanting to determine the time remaining in an active timer, you need something like:

    {% set finish_time = state_attr('timer.timer_entity_id', 'finishes_at') %}
    {{ '00:00' if finish_time == None else (as_datetime(finish_time) - now()).total_seconds() | timestamp_custom('%H:%M', false) }}
    

    Or this version, which breaks hours and minutes into speakable parts:

    {% set finish_time = state_attr('timer.timer_entity_id', 'finishes_at') %} 
    {% set hours, minutes = ('00:00' if finish_time == None else (as_datetime(finish_time) - now()).total_seconds() | timestamp_custom('%H:%M', false)).split(':') | map('int') %} 
    {{ '' if hours == 0 else hours ~ ' hour' if hours == 1 else hours ~ ' hours' }} {{ ' and ' if hours > 0 }} {{ minutes ~ ' minute' if minutes == 1 else minutes ~ ' minutes' }}