Use the following in a Template Condition.
{{ now() - state_attr('automation.night_time', 'last_triggered') < timedelta(hours=12) }}
Use the following in a Template Condition.
{{ now() - state_attr('automation.night_time', 'last_triggered') < timedelta(hours=12) }}