How to fix but no default was specified

I’m getting this Logs error but the template does work. Can anyone telll me how to define a default?

sensor:
  - platform: template
    sensors:
      12h_time:
        friendly_name: "Time No Padding" 
        value_template: >
          {% set time = states('sensor.mytime') %}
          {% set hour = time[:2]|int %}
          {{ '{:2d}:{} {}'.format(hour if hour == 12 else hour % 12, time[3:5], '' if hour>11 else '') }}

template:
  - sensor:
      - name: MyTime
        state: "{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%I:%M%p') }}"
        icon: "mdi:calendar-clock"

It’s the int filter. Change it to something like int(0) where 0 reflects the default.

1 Like

That worked ! Than you !
I wish I knew how to mark this as solved.

Think there is an option to do that by my post.