Set a timer using HA Assist

Hi @DonNL .
Ive recently updated to the newest version of your timer scripts.
The timer reached automation fails however with this error:


My config:

homeassistant:
  customize:
    script.assist_timerstart:
      settings: &settings
        ########################################################
        ### SET THE VARIABLES HERE TO CUSTOMIZE YOUR ROUTINE ###
        ########################################################
        timer_target: "Kitchen" #Which device or room should play the timer? #NOTE: If you choose a room, ALL media_players in that room will be played.
        timer_target_default: "media_player.pi-kitchen" #Which media_player entity should be used if timer_target is none? (Used when dynamic targets are null.)
        #You can also assign a sensor.entity_id or input_text to have a dynamic room or media_player assigned.
        #This can be usefull if, for example, you have a sensor monitoring where Assist is activated, to use it in that specific room or device.

        # Timer settings
        timer_tts: true #Set this to true if you want the timer to be a tts message. Default is true.
        timer_tts_service: "tts.speak" #Which TTS service to use? Default is "tts.speak".
        timer_tts_target: "tts.home_assistant_cloud" #Which TTS target to use, e.g. piper or ha cloud? Default is "tts.home_assistant_cloud".
        timer_tts_message: "A set timer has finished." #You can also assign a sensor or input_text entity_id to have a dynamic tts message.

        #If timer_tts is set to false, the media_location will automatically be used to play the target media file.
        #Use filenamer timer.mp3 to be able to stop the music as well. (For playback recognition).
        #Case sensitive (timer.mp3 vs Timer.mp3)
        timer_media_location: "/media/local/timer.mp3"

        # Timer volume
        timer_volume: 0.4 #What volume level do you want the timer to play at? Device volume level will be restored after the timer has finished.
      ########################################################

Could you have a look?

Hi @freakshock, I found the error in the script.
Line 512 had a " == ā€˜trueā€™" in the template which shouldnā€™t be there. I think a stupid copy and paste error on my end. I updated the package or you can change that line yourself.

Nice to hear itā€™s working now, @celodnb

3 Likes

Thanks for your quick response and fix @DonNL :saluting_face:

1 Like

Hi @DonNL ,

many thanks for your great work. Unfortunately, your timer collides with the BuiltIn Intent HassTimer*, as the German sentences I use are more like the BuildIn sentences. I know you can avoid this by using a different sentence structure, but the system should actually adapt to the user and not the other way around. Apart from that, the BuiltIn function only gives me the error message ā€œI didnā€™t understand itā€ and the match result is false.

Do you see a possibility to combine the two timer versions? Do you know where the error in the BuiltIn timer could lie, or can the BulitIn timer perhaps even be switched off?

Thanks for help.

I have a similair issue where i wanted to create a custom intent to create a reminder (mind you, not a timer) but the OpenAI integration still matches it up to the (currently nonfunctional) Timer intents.

Perhaps you could solve your issue by overriding the built in timer intent by renaming Donā€™s intents with the same names and restarting HA. I have not tried this yet.

Hi @freakshock, I have tried this but it does not work.

Pardon my noobie blunderingsā€¦Iā€™m trying to get the timer stuff working. As far as I can tell it is setup as it should be, but I keep getting ā€˜Something went wrong: unable to find entity [ā€˜timer.timer_1_minuteā€™]ā€™.

If I use the ā€˜sentences parserā€™ tool in the developer tools section it shows:

Start a 1 minute timer:

intent:
  name: TimerStart
slots:
  minutes: '1'
  seconds: 0
  hours: 0
details:
  minutes:
    name: minutes
    value: 1
    text: '1'
  seconds:
    name: seconds
    value: 0
    text: ''
  hours:
    name: hours
    value: 0
    text: ''
targets: {}
match: true
sentence_template: set [(a|an)] {minutes} minute[s] timer
unmatched_slots: {}
source: custom
file: en/assist_timers.yaml

start a 1 minute timer:

intent:
  name: HassStartTimer
slots:
  minutes: '1'
details:
  minutes:
    name: minutes
    value: 1
    text: '1'
targets: {}
match: false
sentence_template: <timer_set>[ a] <timer_duration> timer
unmatched_slots: {}
source: builtin

The name and source in those screenshots being different seems indicative of something, but Iā€™m not sure what.

That might not be enough to help anyone point me in the right direction, but Iā€™d appreciate any pointers!

Edit: sorry about the images, fixed!

Second edit: I think I may have solved my own problems. I was also toying with Extended OpenAI Conversation with the voice assist, changing the conversation agent to Home Assistant seems to have allowed the timer functionality to work fine. Bit of a bummer I canā€™t have both, but the timers are a non-negotiable need for certain people in the houseā€¦

Please see the pinned post on the main forum page. Post the code (correctly formatted) rather than screenshots. This will also fix you issue of not being able to post more imagesā€¦

Hi all, not sure if itā€™s just me, but I have been using Donā€™s scripts etc to make timers for a few weeks now without issue, until today when I upgraded to the latest patch release of HA. Now, when I ask to set a timer on one of my satellites (ESPHome), I get the response ā€˜Sorry, timers are not supported on this deviceā€™. If I do it however on my phone or in the browser, I donā€™t have any problems.

Anyone know what this could be? @DonNL ?

Same stuff. ESPHome 2024.6.0 brought timers support into voice_assistant, but it is somehow broken.

Sorry, not sure what that could beā€¦ I havenā€™t really looked into the new timer function of the 2024.6 release. Still, I believe custom sentences should overwrite default sentences, so not sure what the issue could beā€¦

seems like setting timers via assist in web and mobile clients is broken in 2024.6, even with custom sentences. I think iā€™ve found the proximate cause of the problem & opened a github issue proposing some solutions. If you are also experiencing this issue or are interested in working together on a fix, please feel free to join that conversation. Thx!

I had another ESPhome update today. After that, I can now use the custom scripts / timers made by @DonNL again! Iā€™ve not changed anything in my set up, so a bit strangeā€¦

1 Like

I was searching for timers and found this thread, my intent was to control devices with timers, e.g. switch off light /ac in x minutes. I saw wild scripts in here and just wanted to share my simple working solution, granted, its using gpt4o so maybe thats why my script can be so simple?!

anyhow, I just created a script which takes 3 parameters: delay in seconds, service name, entity name

and In the gpt prompt, I added s sentence to use that script when the user wants to to perform timed service calls. works nicely and super simple.

expose the script to assist.

here is the script:

alias: Delayed Service Execution
fields:
  delay_seconds:
    description: Delay in seconds before executing the service
    example: 60
    required: true
  service_name:
    description: The service to be called (e.g., 'light.turn_on')
    example: light.turn_on
    required: true
  target_entity:
    description: The entity ID to apply the service to
    example: light.living_room
    required: true
sequence:
  - delay: "{{ delay_seconds | int }}"
  - service: "{{ service_name }}"
    target:
      entity_id: "{{ target_entity }}"
mode: parallel
max: 10

sorry if this approach is too naive, just wanted to share that here.

The new timers work quite well.

Am I doing something wrong or do timers not work with ChatGpt as Conversation Agent?
I get the blunt answer that it canā€™t set timers.
Is there a way to use the new ā€œassist timersā€ anyway? Possibly with an exposed script?

Use this. It will call upon local assist first.
m50/ha-fallback-conversation: HomeAssistant Assist Fallback Conversation Agent (github.com)

1 Like

If I use assist on my phone I cant get the timer working in Dutch. The timer works on my athom echo but it doesnā€™t work on my phone using assist. I use microsoft stt and even if I type : ā€œstart een timer voor 2 minutesā€ it doesnā€™t work. If I use the chat gpt conversation agent it does work on my phone. What is the correct sentence to start a timer on my phone in Dutch?



I get an error when starting the home assistant. I have another package working fine this isnā€™t though.