Add documentation for supporting offsets (#33611)

This commit is contained in:
Tsvi Mostovicz 2024-09-16 09:52:13 +03:00 committed by GitHub
parent 855d78c483
commit af018c77bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -751,9 +751,32 @@ automation:
entity_id: light.bedroom
```
### Sensors of datetime device class with offsets
When the time is provided using a sensor of the timestamp device class, an offset can be provided. This offset will be added to (or subtracted from when negative) the sensor value.
For example, this trigger fires 5 minutes before the phone alarm goes off.
```yaml
automation:
- trigger:
- platform: time
at:
entity_id: sensor.phone_next_alarm
offset: -00:05:00
action:
- service: light.turn_on
target:
entity_id: light.bedroom
```
{% important %}
When using a positive offset the trigger might never fire. This is due to the sensor changing before the offset is reached. For example, when using a phone alarm as a trigger, the sensor value will change to the new alarm time when the alarm goes off, which means this trigger will change to the new time as well.
{% endimportant %}
### Multiple times
Multiple times can be provided in a list. Both formats can be intermixed.
Multiple times can be provided in a list. All formats can be intermixed.
```yaml
automation:
@ -762,6 +785,8 @@ automation:
at:
- input_datetime.leave_for_work
- "18:30:00"
- entity_id: sensor.bus_arrival
offset: "-00:10:00"
```
## Time pattern trigger