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