Thanks everyone. Ultimately this is what I came up with:
In my included sensor.yaml:
- platform: template
sensors:
bathroom_delay:
value_template: >
{% if (states.sensor.local_time.state > "05:00") and (states.sensor.local_time.state < "10:00") %}
15
{% else %}
5
{% endif %}
Then in my included script.yaml:
bathroom_motion_helper:
sequence:
- delay: "00:{{ states.sensor.bathroom_delay.state }}:00"
- service: light.turn_off
data:
entity_id: light.over_sink_light_53
bathroom_motion_timer:
sequence:
- service: script.turn_off
data:
entity_id: script.bathroom_motion_helper
- service: light.turn_on
entity_id: light.over_sink_light_53
- service: script.turn_on
data:
entity_id: script.bathroom_motion_helper
Finally in my automations.yaml:
- id: jwe001
alias: Bathroom Motion Detected
trigger:
- entity_id: binary_sensor.eye_motion_71
platform: state
from: 'off'
to: 'on'
action:
- alias: Turn on bathroom lights
service: script.bathroom_motion_timer
hide_entity: true
All the sensor created needs to be hidden from the interface and would not be necessary if we had a delay_template option.