New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Assist timers #117199
Add Assist timers #117199
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
"""Number of seconds the timer should run as given by the user.""" | ||
|
||
created_at: int | ||
"""Timestamp when timer was created (time.monotonic_ns)""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the downside of not using UTC seconds is that we cannot share this info with other consumers. Not sure if we want this? I guess we can add it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Can be merged if my final comments addressed
773a73d
to
6d45a49
Compare
6d45a49
to
bc174f9
Compare
Proposed change
Adds support for timers to Assist. These timers are internal to Assist and do not persist across HA restarts.
Sentences have not been added yet, just intents!
Capabilities
The following capabilities for timers are supported:
Targeting Timers
When performing an action on a timer, such as pausing or cancelling, the timer must be targeted with constraints. Multiple timers cannot be targeted, so the constraints must result in one timer.
The following explicit constraints are supported:
There are also implicit constraints when timers are set with a
device_id
. In this case, timers in the same area are prioritized, followed by timers on the same floor.Attaching Assist Commands
User data may be attached to a timer when started and forwarded to consumers of timer events. A special
data.assist_command
key allows a text command to be executed when the timer is finished.This feature enables sentences like "open the garage door in 5 minutes" and "turn off all lights in an hour".
Implementation
Assist timers are implemented using events and
asyncio.sleep
in background tasks. Timer events include:intent.timer_started
- fired when a timer startsintent.timer_updated
- fired when a timer is paused/unpaused or time is added/removedintent.timer_cancelled
- fired when a timer is cancelledintent.timer_finished
- fired when a timer finishes successfully (not cancelled)Using events makes it very easy for other integrations to make use of Assist timers, and makes it possible to users to create automations with them.
All information about the timer, including the device it was set on and language used to set it, are included with each event.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: