home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.75k stars 28.91k forks source link

assist on web client and android cannot start timers #120058

Open dj-sf opened 2 weeks ago

dj-sf commented 2 weeks ago

The problem

I have been trying to get voice activated timers working for several days now. First I tried using the built in HassStartTimer intent, being sure to adhere to the sentence structures I saw in the yaml file. This only ever produced "Sorry, I couldn't understand that" responses.

I made a HA forum post about this and was told it may be due to the require_context: area param. So I created a custom version of the sentences file (timers.yaml) with that section removed. This led to to new behavior; it correctly interpreted the intent but says the requesting device is incompatible with timers.

Yaml & assist conversation text below:

Default conversation behavior: image

modified timers.yaml without require_context block:

---
language: "en"
intents:
  HassStartTimer:
    data:
      - sentences:
          - "<timer_duration> timer"
          - "timer for <timer_duration>"
          - "<timer_duration> timer for {timer_name:name}"
          - "timer for <timer_duration> (named|called) {timer_name:name}"
          - "<timer_set>[ a] <timer_duration> timer"
          - "<timer_set>[ a] timer for <timer_duration>"
          - "<timer_set>[ a] <timer_duration> timer (named|called|for) {timer_name:name}"
          - "<timer_set>[ a] timer (named|called) {timer_name:name} for <timer_duration>"
          - "<timer_set>[ a] timer for <timer_duration> (named|called) {timer_name:name}"
      - sentences:
          - "{timer_command:conversation_command} in <timer_duration>"
          - "in <timer_duration> {timer_command:conversation_command}"
        response: command

behavior with custom timers.yaml file: image

What version of Home Assistant Core has the issue?

core-2024.6.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Link to forum post: https://community.home-assistant.io/t/hassstarttimer-built-in-intent-not-working-with-assist/741117/4

dj-sf commented 1 week ago

brief update -- i tried labeling my devices with an "area" to see if this made a difference. it did not.

dj-sf commented 1 week ago

After some tinkering locally, I've discovered a few things.

  1. The default HassStartTimer intent initially does not match due to the missing "area" property when running from web client (breakpoint stops here revealing "area" listed in maybe_result.unmatched_entities.)
  2. When using the custom version of that intent without the Area requirement ( see timers.yaml from original post) , the error being thrown is the TimersNotSupportedError on line 815 of the dev branch. This is because it fails the logic check that occurs immediately beforehand -- conversation_command & intent_obj.device_id are both None, and the device, not having an id, is not registered with the timer_manager.

Therefore, I'd like to propose some possible fixes:

First, we should either remove the area requirement from the default intent OR give the clients some sort of placeholder area value so that requirement is fulfilled.

Second, we should either modify the default attributes of the web & mobile clients so that they can pass this logic check out of the box OR we should change this logic to allow them to use the timer intents with their current attributes.

@synesthesiam I see that you have worked on the timer logic quite a bit. Do you know if any of these proposed solutions might work?

weberruss commented 3 hours ago

It should be also possible to start, stop, ... already existing timer with their default duration entities in HA with a sentance like "start timer {timer_name:name}" so the timer duration needs to be an optional parameter.