Just getting started with intents. Thinking of my most-requested of Alexa, so far I have “what time is it”, “what day is it”, and “when is {holiday}”
Those first intents were pretty easy to create, but now I’m trying to set a timer. This works if I say it correctly with regard to my template but it just looks like I’m doing it wrong. It looks like repetitive and just a mess. I’m coming back to the community experts to ask for help to improve this or simplify it if possible.
Also, local lists gives an error so I’m not using that option.
language: "en"
intents:
TimerSet:
data:
- sentences:
- "set (a | the) timer for {duration1} {time_unit1} [and] [{duration2} {time_unit2}] [and] [{duration3} {time_unit3}]"
lists:
duration1:
values:
- in: "one"
out: "1"
- in: "two"
out: "2"
- in: "three"
out: "3"
- in: "four"
out: "4"
- in: "five"
out: "5"
- in: "six"
out: "6"
- in: "seven"
out: "7"
- in: "eight"
out: "8"
- in: "nine"
out: "9"
- "1"
- "2"
- "3"
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
- "16"
- "17"
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
- "37"
- "38"
- "39"
- "40"
- "41"
- "42"
- "43"
- "44"
- "45"
- "46"
- "47"
- "48"
- "49"
- "50"
- "51"
- "52"
- "53"
- "54"
- "55"
- "56"
- "57"
- "58"
- "59"
duration2:
values:
- in: "one"
out: "1"
- in: "two"
out: "2"
- in: "three"
out: "3"
- in: "four"
out: "4"
- in: "five"
out: "5"
- in: "six"
out: "6"
- in: "seven"
out: "7"
- in: "eight"
out: "8"
- in: "nine"
out: "9"
- "1"
- "2"
- "3"
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
- "16"
- "17"
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
- "37"
- "38"
- "39"
- "40"
- "41"
- "42"
- "43"
- "44"
- "45"
- "46"
- "47"
- "48"
- "49"
- "50"
- "51"
- "52"
- "53"
- "54"
- "55"
- "56"
- "57"
- "58"
- "59"
duration3:
values:
- in: "one"
out: "1"
- in: "two"
out: "2"
- in: "three"
out: "3"
- in: "four"
out: "4"
- in: "five"
out: "5"
- in: "six"
out: "6"
- in: "seven"
out: "7"
- in: "eight"
out: "8"
- in: "nine"
out: "9"
- "1"
- "2"
- "3"
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
- "16"
- "17"
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
- "37"
- "38"
- "39"
- "40"
- "41"
- "42"
- "43"
- "44"
- "45"
- "46"
- "47"
- "48"
- "49"
- "50"
- "51"
- "52"
- "53"
- "54"
- "55"
- "56"
- "57"
- "58"
- "59"
time_unit1:
values:
- "hour[s]"
- "minute[s]"
- "second[s]"
time_unit2:
values:
- "minute[s]"
- "second[s]"
time_unit3:
values:
- "second[s]"
intent_script:
TimerSet:
action:
- service: timer.start
target:
entity_id: timer.voice_timer
data:
duration: >-
{%- if time_unit1 == 'hour[s]' -%}
{{ '%02d' % duration1 | int + ':' }}
{%- if duration2 == empty -%}
{{ '00:' }}
{%- else -%}
{{ '%02d' % duration2 | int + ':'}}
{%- endif %}
{%- if duration3 == empty -%}
{{ '00' }}
{%- else -%}
{{ '%02d' % duration3 | int }}
{%- endif %}
{%- elif time_unit1 == 'minute[s]' -%}
{{ '00:' + '%02d' % duration1 | int + ':' }}
{%- if duration2 == empty -%}
{{ '00' }}
{%- else -%}
{{ '%02d' % duration2 }}
{%- endif %}
{%- elif time_unit1 == 'second[s]' -%}
{{ '00:00:' + '%02d' % duration1 | int }}
{%- endif %}
speech:
text: "timer started"