How to guard this template binary_sensor for availability

considering this:

    motion_light:
      friendly_name: Motion light
      value_template: >
        {% set updater = states('sensor.sensors_huidig_verbruik_summed') %}
        {{(now() -
             state_attr('automation.update_light_motion','last_triggered')).total_seconds()
             < 10}}

which always exists in the config, except apparently when reloading templates, I would need a guard for the attributes last_triggered:

Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:71 
Integration: template (documentation, issues) 
First occurred: 2:24:37 PM (1 occurrences) 
Last logged: 2:24:37 PM

TemplateError('TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'') while processing template 'Template("{% set updater = states('sensor.sensors_huidig_verbruik_summed') %} {{(now() - state_attr('automation.update_light_motion','last_triggered')).total_seconds() < 10}}")' for attribute '_state' in entity 'binary_sensor.motion_light'

most of the time is use some overkill in the templates just to be sure:

        availability_template: >
          {% set id = state_attr('automation.update_light_motion','last_triggered') %}
          {% set un = ['unknown','unavailable'] %}
          {{id not in un and id is not none}}

or would some other issue be at hand here?