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') }}