Set Timer with Rhasspy

Hi,

I’m trying with rhasspy (https://rhasspy.readthedocs.io/en/latest/) and this template (https://github.com/synesthesiam/rhasspy-nlu/blob/559a98eb560295f14e3d65499d88d2af6901d8b1/etc/timer.ini) to start a timer via Home Assistant.

I’ve done that so far:

  SetTimer:
    action:                                                        
    data_template:
            duration: "{{ stunden if stunden != 'undefined' else '00' }}:{{ minuten if minuten != 'undefined' else '00' }}:{{ sekunden if sekunden != 'undefined' else '00' }}"
    entity_id: timer.timer1
    service: timer.start

but this error message comes up

Logger: homeassistant.helpers.intent
Source: helpers/intent.py:73
First occurred: 22:08:56 (1 occurrences)
Last logged: 22:08:56

Received invalid slot info for SetTimer: offset :10: should be format ‘HH:MM’, ‘HH:MM:SS’ or ‘HH:MM:SS.F’ for dictionary value @ data[‘duration’]

can someone help me? Thanks

Did you ever find your mistake?
It looks like the values might not be ‘undefined’ but empty.

No, unfortunately not.

I’ve helped myself so much that I’ve created several intents at rhasspy:

SetTimerHourMinute
SetTimerMinuteSeconds
SetTimerMinute
SetTimerHour

I fill the missing variables with “00”

I have gotten the sentences.ini spec to work without setting multiple intents

Paste this in as your intent_script for setting the timer:

SetTimer:
    action:
      - service: timer.start
        target:
          entity_id: timer.timer1
        data_template:
          duration: "{{ hours if hours != NULL else '00' }}:{{ minutes if minutes != NULL else '00'}}:{{ seconds if seconds != NULL else '00' }}"
    speech:
      text: Timer set for {{ hours if hours != NULL }} {{ 'hours' if hours != NULL }} {{ minutes if minutes != NULL }} {{ 'minutes' if minutes != NULL }} {{ seconds if seconds != NULL }} {{ 'seconds' if seconds != NULL }}

I think there are some mistakes in the timer.ini you refrenced so I adjusted my ini and it looks like this (I did it in german but it looks like you actually might be looking for this):

[Zahlen]
eins_bis_neun = ((ein | eine | eins | erst | erste):1 | (zwei | zweite):2 | (drei | dritte):3 | (vier | vierte):4 | (fünf | fünfte):5 | (sechs | sechste):6 | (sieben | siebte | siebente):7 | (acht | achte):8 | (neun | neunte):9)
zehn_bis_neunzehn = ((zehn | zehnte):10 | (elf | elfte):11 | (zwölf | zwölfte):12 | (dreizehn | dreizehnte):13 | (vierzehn | vierzehnte):14 | (fünfzehn | fünfzehnte):15 | (sechszehn | sechszehnte):16 | (siebzehn | siebzehnte):17 | (achtzehn | achtzehnte):18 | (neunzehn | neunzehnte):19)
zehner_bis_neunzig = ((zwanzig | zwanzigste):20 | (dreißig | dreißigste):30 | (vierzig | vierzigste):40 | (fünzig | fünfzigste):50 | (sechzig | sechzigste):60 | (siebzig | siebzigste):70 | (achtzig | achtzigste):80 | (neunzig | neunzigste):90)
einhundert_bis_neunhundert = <eins_bis_neun> (hundert | hundertste:hundert)
eins_bis_neunzehn = (<eins_bis_neun> | <zehn_bis_neunzehn>)
eins_bis_neunundneunzig = (<eins_bis_neunzehn> | [<eins_bis_neun> und] <zehner_bis_neunzig>)

[SetTimer]
stunde_halb_ausdruck = (<Zahlen.eins_bis_neun>{stunden} ein (halb){minuten:30} | (andert){stunden:1} (halb){minuten:30})
stunde_ausdruck = (((<Zahlen.eins_bis_neun>){stunden}) | <stunde_halb_ausdruck>) (stunde | stunden)

minute_halb_ausdruck = (<Zahlen.eins_bis_neunundneunzig>{minuten} ein (halb) {sekunden:30} | (andert){minuten:1} (halb){sekunden:30})
minute_ausdruck = (((<Zahlen.eins_bis_neunundneunzig>){minuten}) | <minute_halb_ausdruck>) (minute | minuten)

sekunde_ausdruck = (((<Zahlen.eins_bis_neunundneunzig>){sekunden})) (sekunde | sekunden)

zeit_ausdruck = ((<stunde_ausdruck> [[und] <minute_ausdruck>] [[und] <sekunde_ausdruck>]) | (<minute_ausdruck> [[und] <sekunde_ausdruck>]) | <sekunde_ausdruck>)

(stell | stelle | setze) [einen] timer (auf | für) <zeit_ausdruck>
timer (auf | für) <zeit_ausdruck>

And the Intent:

SetTimer:
  action:
    - service: timer.start
      data:
        entity_id: timer.rhasspy
        duration: >
          {% if stunden is not defined %}
            {% set stunden = '00' %}
          {% else %}
            {% set stunden = stunden %}
          {% endif %}

          {% if minuten is not defined %}
            {% set minuten = '00' %}
          {% elif 'und' in minuten %}
            {% set minuten_liste = minuten.split(' und ') %}
            {% set minuten = (minuten_liste[1] | first) + minuten_liste[0] %}
          {% else %}
            {% set minuten = minuten %}
          {% endif %}

          {% if sekunden is not defined %}
            {% set sekunden = '00' %}
          {% elif 'und' in sekunden %}
            {% set sekunden_liste = sekunden.split(' und ') %}
            {% set sekunden = (sekunden_liste[1] | first) + sekunden_liste[0] %}
          {% else %}
            {% set sekunden = sekunden %}
          {% endif %}

          {{ stunden }}:{{ minuten }}:{{ sekunden }}

I’m actually in the middle of moving this to python because the Intents are getting convoluted but I hope you get the gist.

Hi guys,
I got the rhasspy part so now it recognize the intent correctly and passes it to Home Assistant that recognize the intent and reply with the text specified.
The point is that in the Core log i found this:
“Unable to find referenced entities timer.timer1 or it is/they are currently not available” and moreover I would like to know how it’s possible to manage the reply back to Rhasspy to tell something like “hey, timer ender, it passes!”.
Am I supposed to install another integration (eg timer) or manually configure the timer entity?
Thanks a lot!

It sounds like you haven’t created a timer in Home Assistant yet. It’s part of the default config, so no further installation required. Documentation is here.

I’ve made this into english in case anyone else wants to use it

[numbers]
one_to_nine = ((one | first):1 | (two | second):2 | (three | third):3 | (four | fourth):4 | (five | fifth) :5 | (six | sixth):6 | (seven | seventh | seventh):7 | (eight | eighth):8 | (nine | ninth):9)
ten_to_nineteen = ((ten | tenth):10 | (eleven | eleventh):11 | (twelve | twelfth):12 | (thirteen | thirteenth):13 | (fourteen | fourteenth):14 | (fifteen | fifteenth):15 | (sixteen | sixteenth):16 | (seventeen | seventeenth):17 | (eighteen | eighteenth):18 | (nineteen | nineteenth):19)
tens_to_ninety = ((twenty | twentieth):20 | (thirty | thirtieth):30 | (forty | fortieth):40 | (fifty | fiftieth):50 | (sixty | sixtieth):60 | (seventy | seventieth):70 | (eighty | eightieth):80 | (ninety | ninetieth):90)
one hundred_to_nine hundred = <one_to_nine> hundred
one_to_nineteen = (<one_to_nine> | <ten_to_nineteen>)
one_to_ninety_nine = (<one_to_nineteen> | [<one_to_nine> and] <tens_to_ninety>)

[SetTimer]
hour_half_expression = (<numbers.one_to_nine>{hours} and a half {minutes:30})
hour_expression = (((<numbers.one_to_nine>){hours}) | <hour_half_expression>) (hour | hours)

minute_half_expression = (<numbers.one_to_ninety_nine>{minutes} and a half minutes {seconds:30})
minute_expression = (((<numbers.one_to_ninety_nine>){minutes}) | <minute_half_expression>)

second_expression = (((<numbers.one_to_ninety_nine>){seconds})) (second | seconds)

time_expression = ((<hour_expression> [[and] <minute_expression>] [[and] <second_expression>]) | (<minute_expression> [[and] <second_expression>]) | <second_expression>)

set [a] timer (on | for) <time_expression>
timer (on | for) <time_expression>

I use NodeRed to handle the intents. You need to “catch” any of the hours, minutes or seconds if they aren’t provided and set them to zeros. Then you can trigger a timer sending duration like this
{"duration":"{{payload.event.hours}}:{{payload.event.minutes}}:{{payload.event.seconds}}"}