Voice controlled timer

Hello,
New to HA and Rhasspy but have managed to get a server/satellite configuration working with several intents working for lighting, tv, roku’s, weather etc. I manage by borrowing code from here and there, but at this point have not been successful first, to fully grasp the mechanisms involved in setting a timer and controlling it and second finding the code examples to figure it out. I can post the Automation Yaml and the Rhasspy sentences that at least don’t throw any errors! But would love some help understanding how to get it functioning.

HA yaml–
alias: Rhasspy SetTimer
description: “”
trigger:

  • platform: event
    event_type: rhasspy_SetTimer
    action:
  • variables:
    hours: >
    {% set h = trigger.event.data.hours %} {{ ‘0’~h if h is defined else
    ‘00’}}
    minutes: >
    {% set m = trigger.event.data.minutes %} {{ m if m is defined else
    ‘00’}}
    seconds: >
    {% set s = trigger.event.data.seconds %} {{ s if s is defined else
    ‘00’}}
  • service: timer.start
    data:
    entity_id: timer.timer
    duration: “{{ hours }}:{{ minutes }}:{{ seconds }}”
    mode: single

Rhasspy–

Timer

[SetTimer]
seconds = (1){seconds!int} seconds | (2…59){seconds!int}seconds
minutes = (1){minutes!int} minute | (2…59){minutes!int}minutes
hours = (1){hours!int} hour | (2…24){hours!int}hours
set [a] timer for
set [a] timer for
set [a] timer for
set [a] timer for [and]
set [a] timer for [and]
set [a] timer for [and][and]

Hi. I started using Rhasspy and HA very recently as well and I am definitely planning to implement a Timer automation soon.

From what I know, Rhasspy will not send the seconds, minutes or hours to HA. The sentences that you write in your sentences.ini are just used for intent detection. The name of the intent [SetTimer] is the only thing that is sent to HA. So your Rhasspy will detect that you are trying to set a timer and send SetTimer event to HA. But the time information is not passed on.

I may be wrong here but that is what I understand from a couple of automations that I have done so far. But I will try to implement this and see if we can find a solution.

much more flexible than that - see https://rhasspy.readthedocs.io/en/latest/training/#sentencesini. Everything is in the Rhasspy documentation, but it can be a pain trying to find what you want.

Ah! Understood. I have only used the intent names so far. Thank you for pointing that out.

Thanks for the link. But I didn’t see anything that would relate to a timer or assist in getting one functioning. What did I miss?

The options the syntax in sentence.ini offers is very flexible.

E.g. the following allows to set timer on all kind of switchable gadgets (using FHEM as controller).

[de.fhem:SetTimedOnOff]
den=<de.fhem:SetOnOff.den>
cmdmulti=<de.fhem:SetOnOff.cmdmulti>
rooms=<de.fhem:SetOnOff.rooms>
<cmdmulti> <den> $de.fhem.Device-SetOnOff{Device} [<rooms>] für [((1..60){Hour!int} (stunde stunden))] [und] [((1..60){Min!int} (minute minuten))] [und] [((1..60){Sec!int} (sekunde sekunden))] <de.fhem:SetOnOff.onOff>
<cmdmulti> <den> $de.fhem.Device-SetOnOff{Device} [<rooms>] bis um (0..24){Hourabs!int} uhr [(1..60){Min!int}] <de.fhem:SetOnOff.onOff>

FHEM then catches the given data fields ({Hour} or {Hourabs}, {Min} and/of {Sec} to do all the relevant calculations. Imo this will always have to be handled on the controller side, so you will have to develop respective code.

@Winston_Smith that post was for Moribus, re other sentences.ini options.

As for a timer, it seems like a very useful addition, so I am also interested … but not so much that I have extensively researched … yet.
I now use node-RED for my automations, but the “timer” posts in their forum were all about different custom add-ons, and I would prefer to stick to built-in functionality if I can.

I use Rhasspy to set timers, Node-RED for the fulfilment, and Node-RED starts a timer in Home Assistant. You don’t really need HA for the timers – it can all be done in Node-RED – but I already have a number of automations in HA for timers, and I wanted a way to stop/start them with my voice instead of the HA dashboard.

This is what I have in Rhasspy intents/timers.ini

[StartVariableTimer]
(start | set) (a | the) [timer for] (1..3){hour} (hours | hour) [timer]
(start | set) (a | the) [timer for] (1..3){hour} (hours | hour) [and] (1..59){minute} (minutes | minute) [timer]
(start | set) (a | the) [timer for] (1..120){minute} (minutes | minute) [timer]
(start | set) (a | the) [timer for] (1..59){minute} (minutes | minute) [and] (1..59){second} (seconds | seconds) [timer]
(start | set) (a | the) [timer for] (1..120){second} (seconds | seconds) [timer]

[GetTimer]
how (long | much time) [is there | is left | remains] (until | on) [the] timer [is done | ends]

[EndTimer]
(stop | end | cancel) [the] timer

I am using ‘Mozilla Deep Speech’ for my speech to text, and it’s pretty good. Sometimes gets confused with numbers like 13 vs 30, 15 vs 50.

In Node-RED I have a timers flow that handles the intent, starting/stopping timers in Home Assistant

For example, the StartVariableTimer flow is as follows

duration functions node:

let hour = msg.slots.hour == null ? 0 : msg.slots.hour
let minute = msg.slots.minute == null ? 0 : msg.slots.minute
let second = msg.slots.second == null ? 0 : msg.slots.second

msg.duration = hour*3600 + minute*60 + second
return msg

StartVariableTimer call service node

and the tts output function is

let h = msg.slots.hour
let m = msg.slots.minute
let s = msg.slots.second

let hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""
let mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""
let sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""

msg.payload = "Alright! Starting a timer for "
msg.payload += hDisplay + mDisplay + sDisplay

return msg

(Not shown here is that you need to take the tts output (the returned message above) and send it back to Rhasspy to actually say the text.)

Hope this working example helps you.

Thanks! Definitely a help.