Template debug - Where to put the default values?

Having read through the existing posts on this and tried a few alterations to my template I’m still getting the following log error:

Template warning: 'as_timestamp' got invalid input 'unavailable' when rendering template '{{ ((states('sensor.sm_g980f_next_alarm') | as_timestamp | int - now() | as_timestamp | int) / 60) | int }}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2021.12

Could anyone help with the following template please? How do I amend this to provide a default value?

# Minutes until next alarm set on mobile phone.    
template:
  - sensor:
      - name: "Minutes Until Next Alarm"
        unit_of_measurement: "m"
        state: >-
          {{ ((states('sensor.sm_g980f_next_alarm') | as_timestamp | int - now() | as_timestamp | int) / 60) | int }}
        attributes:
          time: >-
            {{ state_attr('sensor.sm_g980f_next_alarm', 'Local Time') }}
        availability: >-
          {{ not is_state('sensor.sm_g980f_next_alarm', 'unavailable') }}

Did you read this one? It provides a very thorough explanation and even includes an example for as_timestamp.

Try: as_timestamp(0) and int(0).

Which version of Home Assistant are you using? I thought the latest one doesn’t evaluate the state template if the availability template is false.