Here’s an example of a Template Condition that checks if the current time (in seconds since midnight) is in between two boundary times (also represented as seconds since midnight). The boundaries are simply the input_datetime’s timestamp
value plus or minus the specified number of hours (in seconds).
- condition: template
value_template: >
{% set q = state_attr('input_datetime.night_quiet_mode_on_time', 'timestamp') %}
{% set t = (now() - now().replace(hour=0, minute=0, second=0, microsecond=0)).seconds %}
{{ q - 7200 <= t <= q + 10800 }}
EDIT
I’ll need you to confirm that I’ve correctly interpreted the meaning of your boundary values. Here’s how I understood it:
If quiet_time is at 19:00 then I understand the time range is from 17:00 to 22:00 (2 hours before to 3 hours after quiet_time’s value).