Set a timer using HA Assist

Great stuff. Just what I have been looking for.
Do anyone else have this problem?
When i say “Set the timer for 1 minute” the Assist think I say “Set the timer for one minute”? The same thing for 2, but when I am saying 12 the the Assist write 12 back and I can set the timer. So I cannot set the timer for 1 hour.
I’m using the Home Assistant Cloud for speech to text.

I created a fork which among other things addresses the issue with advertised numbers from stt.
Basically i created a list containing the advertised numbers mapped to their digits:

lists:
  advertised_timer_values:
    values:
      - in: one
        out: 1
      - in: two
        out: 2
       .
       .
       .

and use these additionally for the slot like so:

({advertised_timer_values:seconds}|{seconds})

(i’m using expansion rules to make it a bit easier)

I also created reminders that can alert you with some text via tts. Have a look at my packages/assist/timer.yaml file for some insights.

2 Likes

Ah good thinking. I was thinking of creating the list somehow too, but nice thinking using the advertised_timer_values

Thank you @hannemann
I have made my own modifications to the script, and it works perfectly.
This is quickly becomming my favorite feature in HA.

this is awesome thanks guys but for the life of me how the hell do you get it to beep/alarm on the device you asked for the alarm on? Or do I just have to setup an automation to send a sound to a specific speaker? I haven’t figured out how to do an automation for “if the command came from this device then set the beeper to that speaker” type scenario

Sadly this is not possible to let the device act as a media player yet. …AFAIK
You cannot have a media player on esphome with esp-idf. If that’s what you meant

If you need room aware voice assistant satelite than please upvote

My approach to solve this problem is to update a text_input entity by the voice assistant satellite like so:

substitutions:
  area_name: living_room
.
.
.
voice_assistant:
.
.
.
  on_stt_end:
    then:
    - homeassistant.service:
        service: input_text.set_value
        data:
          value: "${area_name}"
          entity_id: input_text.va_current_device
.
.
.

I have set up a NR automation that notifies me on different media players depending on the room I’m in, when the timer goes idle.

1 Like

that’s a great idea, I better get some more sensors around the house LOL

1 Like

Cheers and voted.
Hmmmm, bugger about the media player on esp-idf, I just bought stuff off Aliexpress that should be ‘good’ enough to be a media player as well, well for simple notifications and crappy music… we live and learn LOL

Yeah, for now using a wake word and a media player requires different esp configuration types and they are mutually exclusive. I am pretty sure devs are aware of this and are doing some testing on a new VAD (voice activity detection) system that will allow both. Although it “can” be done by eliminating VAD it is not ideal so I think we have to wait.

I updated the custom_sentences within my repo with 2 things;

  1. Added support for area’s (only for esphome satelites).
  2. Added @hannemann 's fix when Assist processes text (one) instead of numbers (1).
2 Likes

Having your Dutch files in the repo would be nice too, I didnt find it on github search.
Thanks a lot👍

1 Like

I built upon DonNL’s work (thanks for the ground work!) and added support for

  • Add to timer
  • Remove from timer
  • Pause/Resume timer
  • Expanded timer name recognition (one, two, three, first, second, third, A, B, C)

It seems to work fine on my end, but I’m sure more eyes (ears!) will find improvements/fixes to be made.
You can check it out here, timer stuff is in time.yaml files (large speech templates are in individual scripts for easier reuse) and configuration.yaml for the intent scripts. There’s also other stuff in there, alarm, time calc, and non-time-related intents… Everything is using my custom notify scripts (also in there), but you can easily change that to plain TTS if you prefer.

2 Likes

I’m using Telegram and routines on my Galaxy 21 for this. You can make a routine on your phone that triggers when you get a Telegram message with a specific text in it. By example if i get a telegram message on my phone with “kjghskdhgsk” (quotes included) in it, it sets a timer for 5 minutes on my phone (and smartwatch) I send the telegram message through HA triggered by a sentence. (set timer 5 minutes)

Works very well, also for other purposes. (alarm triggered, or change sleep mode and do not disturb) You can also make a routine that reads a message out loud on your phone (someone rang the doorbell), again, triggered by a Telegram message with a specific keyword. Play music, possibilities are endless if you have Telegram setup in your Home Assistant and use the routine function from your phone. Very powerfull

Nice one. I will look into this later.

1 Like

On top of not being originally designed for voice use, timers need a lot of rework in my opinion.
You have to work around a lot of limitations (not being able to increase past original duration, a remaining attribute that’s not really “remaining” unless the state of the timer changes…). You end up having to calculate everything by hand…

3 Likes

unfortunately the timers aren’t working for me. it says “Unexpected error during intent recognition” when i say “set a timer for 1 minute”

Which ones did you try to setup?
Did you check HA’s logs right after asking? It should give a more precise idea of what’s going wrong.
You can also test the matching manually in Developer Tools > Assist, you write the sentence as you think it should match, and it will tell you if it finds a matching intent (indicating if your sentence’s format is wrong or your intent is not properly configured).

PS: Many of these number-dependent intents should become a lot easier to handle as soon as HA updates to the new parser version, that fixes the broken number words recognition.

Update: Intents cleaned up with 2024.2 now supporting numbers without nasty workarounds. You can find the full list here.

Let’s do some math… :grin:

1 Like

Nice! Will look into that. Im actually working on a timer package to get a simpler but working solution. Nearly done.

2 Likes