Using the input_datetime directly in an automation trigger with the Time platform is great!
Currently there is no trigger state object data/variable for the entity (input_datetime) used in the Time platform trigger.
Here is an automation example:
- id: Timer - Study Lamp
alias: Timer - Study Lamp
description: ''
trigger:
- platform: time
at: input_datetime.study_lamp_on_time
- platform: time
at: input_datetime.study_lamp_off_time
condition:
- condition: state
entity_id: input_boolean.study_lamp_timer
state: 'on'
action:
- choose:
- conditions:
- condition: template
value_template: >-
{{ trigger.platform == 'time' and (as_timestamp(trigger.now) |
timestamp_custom('%H:%M', true) ) ==
(states('input_datetime.study_lamp_on_time') [0:5] ) }}
sequence:
- service: light.turn_on
data: {}
entity_id: light.study
- conditions:
- condition: template
value_template: >-
{{ trigger.platform == 'time' and (as_timestamp(trigger.now) |
timestamp_custom('%H:%M', true) ) ==
(states('input_datetime.study_lamp_off_time') [0:5] ) }}
sequence:
- service: light.turn_off
data: {}
entity_id: light.study
default: []
mode: restart
If it can be accommodated, I’d like to see a trigger.entity_id variable added to represent the input_datetime used in the time trigger.
This would simplify the templating by allowing a simple entity comparison be used rather than the more complicated time comparison.
Current:
value_template: >-
{{ trigger.platform == 'time' and (as_timestamp(trigger.now) |
timestamp_custom('%H:%M', true) ) ==
(states('input_datetime.study_lamp_on_time') [0:5] ) }}
Proposed:
value_template: >-
{{ trigger.platform == 'time' and
trigger.entity_id == 'input_datetime.study_lamp_on_time' }}