You don’t need to use timestamp at all…
template:
binary_sensor:
state: >
{% set event = state_attr('calendar.general_bin', 'start_time') | as_datetime | as_local %}
{% set delta = event - now() %}
{{ iif(timedelta(hours=8) < delta or delta <= timedelta(), 'off', 'on') }}
availability: >
{{ state_attr('calendar.general_bin', 'start_time') is not none }}
If you want to continue using as_timestamp
:
1 Like