Sonos Set Alarm with Variable - datetime.datetime' and 'int' Error

I’m currently trying to program my Sonos Alarm via Home Assistant.

If I run the following command every thing works as intended:

media_player.sonos_update_alarm
{
  "alarm_id": "156",
  "enabled": "true",
  "entity_id": "media_player.schlafzimmer",
  "time": "06:30"
}

However if I run:

media_player.sonos_update_alarm
{
  "alarm_id": "156",
  "enabled": "true",
  "entity_id": "media_player.schlafzimmer",
  "time": "{{ states.sensor.alarm_clock_wd_time.state }}"
}

I get the error:
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'int'

The variable Im using is defined as

  alarm_clock_wd_time:
    friendly_name: 'Alarm Time'
    icon_template: 'mdi:alarm'
    value_template: '{{ "%0.02d:%0.02d" | format(states.input_number.alarm_clock_wd_hour.state | int, states.input_number.alarm_clock_wd_minute.state | int ) }}'

Got it working with the some help in the discord channel. The trick was to cast the template into a string: time: “{{ states(‘sensor.alarm_clock_wd_time’)|string}}”