I’d like to have a binary sensor that is true when the current time is between two input helper datetime variables.
I’ve tried this but it doesn’t work - but it might explain what I mean:
- platform: tod
name: Within time window
after_offset: "{{ states('input_datetime.start_time') }}"
before: "{{ states('input_datetime.stop_time') }}"
How can I do this in a reasonable way? I use node-red for automations, but I make use of template sensors for combined sensors as I find it easier to reason about.
The use case here is to turn on a lamp outside of the kids bedroom, but only if it’s dark enough and not after bedtime for them (so that the lamp doesn’t turn on while putting them to bed, waking them up). I’d like to change these time windows as needed, without having to edit the template sensor or changing the automation.
Thanks, but it doesn’t work (but thanks for noticing my typo! :D)
Invalid config for [binary_sensor.tod]: Invalid time specified: {{ states('input_datetime.stop_time') }} for dictionary value @ data['before']. Got "{{ states('input_datetime.stop_time') }}"
Invalid time specified: {{ states('input_datetime.start_time') }} for dictionary value @ data['after']. Got "{{ states('input_datetime.start_time') }}". (See ?, line ?).