diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index a1b0dad098c..21278718803 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -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