Hi All
I know this question regarding template and defaults gets asked a lot, so apologies in advance.
I have read 101 post about this subject and get most of it but dont know where I am missing the defaults from the following, so any advice appreciated as I have now given up.
Template:
{% set timenow = now().timestamp() %}
{% set event = state_attr('calendar.general_bin', 'start_time') | as_timestamp %}
{% set delta = (event - timenow) | int %}
{% if delta <= 0 %} off {% elif delta <= 28800 %} on
{% else %} off {% endif %}
Error:
TemplateError(āValueError: Template error: as_timestamp got invalid input āNoneā when rendering template ā{% set timenow = now().timestamp() %} {% set event = state_attr(ācalendar.general_binā, āstart_timeā) | as_timestamp %} {% set delta = (event - timenow) | int %} {% if delta <= 0 %} off {% elif delta <= 28800 %} on {% else %} off {% endif %}ā but no default was specifiedā) while processing template āTemplate(ā{% set timenow = now().timestamp() %} {% set event = state_attr(ācalendar.general_binā, āstart_timeā) | as_timestamp %} {% set delta = (event - timenow) | int %} {% if delta <= 0 %} off {% elif delta <= 28800 %} on {% else %} off {% endif %}ā)ā for attribute ā_stateā in entity ābinary_sensor.general_bin_tomorrowā
Thanks in advance, I know its related to timestamp but failing to see where to put a default in.
Ross