mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 09:17:06 +00:00
Time trigger can also accept an input_datetime Entity ID (#14207)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
445a7a0d5e
commit
a89d99be20
@ -282,9 +282,10 @@ automation:
|
|||||||
The `for` template(s) will be evaluated when the `value_template` becomes `true`.
|
The `for` template(s) will be evaluated when the `value_template` becomes `true`.
|
||||||
|
|
||||||
<div class='note warning'>
|
<div class='note warning'>
|
||||||
|
|
||||||
Rendering templates with time (`now()`) is dangerous as trigger templates are only updated based on entity state changes.
|
Rendering templates with time (`now()`) is dangerous as trigger templates are only updated based on entity state changes.
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
As an alternative, providing you include the sensor [time](/integrations/time_date/) in your configuration, you can use the following template:
|
As an alternative, providing you include the sensor [time](/integrations/time_date/) in your configuration, you can use the following template:
|
||||||
|
|
||||||
@ -303,7 +304,11 @@ which will evaluate to `True` if `YOUR.ENTITY` changed more than 300 seconds ago
|
|||||||
|
|
||||||
### Time trigger
|
### Time trigger
|
||||||
|
|
||||||
The time trigger is configured to fire once at a specific point in time each day.
|
The time trigger is configured to fire once a day at a specific time, or at a specific time on a specific date. There are two allowed formats:
|
||||||
|
|
||||||
|
#### Time String
|
||||||
|
|
||||||
|
A string that represents a time to fire on each day. Can be specified as `HH:MM` or `HH:MM:SS`. If the seconds are not specified, `:00` will be used.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
automation:
|
automation:
|
||||||
@ -313,15 +318,55 @@ automation:
|
|||||||
at: "15:32:00"
|
at: "15:32:00"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or at multiple specific times:
|
#### Input Datetime
|
||||||
|
|
||||||
|
The Entity ID of an [Input Datetime](/integrations/input_datetime/).
|
||||||
|
|
||||||
|
has_date | has_time | Description
|
||||||
|
-|-|-
|
||||||
|
`true` | `true` | Will fire at specified date & time.
|
||||||
|
`true` | `false` | Will fire at midnight on specified date.
|
||||||
|
`false` | `true` | Will fire once a day at specified time.
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
automation:
|
||||||
|
- trigger:
|
||||||
|
platform: state
|
||||||
|
entity_id: binary_sensor.motion
|
||||||
|
to: 'on'
|
||||||
|
action:
|
||||||
|
- service: climate.turn_on
|
||||||
|
entity_id: climate.office
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
entity_id: input_datetime.turn_off_ac
|
||||||
|
data_template:
|
||||||
|
datetime: >
|
||||||
|
{{ (now().timestamp() + 2*60*60)
|
||||||
|
| timestamp_custom('%Y-%m-%d %H:%M:%S') }}
|
||||||
|
|
||||||
|
- trigger:
|
||||||
|
platform: time
|
||||||
|
at: input_datetime.turn_off_ac
|
||||||
|
action:
|
||||||
|
service: climate.turn_off
|
||||||
|
entity_id: climate.office
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
|
#### Multiple Times
|
||||||
|
|
||||||
|
Multiple times can be provided in a list. Both formats can be intermixed.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
automation:
|
automation:
|
||||||
trigger:
|
trigger:
|
||||||
platform: time
|
platform: time
|
||||||
at:
|
at:
|
||||||
- "15:32:00"
|
- input_datetime.leave_for_work
|
||||||
- "20:30:00"
|
- "18:30:00"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Time pattern trigger
|
### Time pattern trigger
|
||||||
|
Loading…
x
Reference in New Issue
Block a user