Card - Person - State Zone (away) vs Geolocation

Can anyone please point me on using my template logic. I have it working in the template editor but cant seem to apply it to an entity card to show on a lovelace page.

{% if( (state_attr("sensor.caitlyn_geocoded_location", "Zones") | list | length <0)
      ) -%}
 Caitlyn is at {{ state_attr("sensor.caitlyn_geocoded_location", "Locality") }}
{%- else -%}
  Caitlyn is at {{ state_attr("sensor.caitlyn_geocoded_location", "Zones")[0] }}.
{%- endif %}

Have tried to create a platform template in configuration.yaml but have not been able to figure that out.

  - platform: template
    sensors: 
     sharon_zone_override:
     friendly_name: "Sharon Zone"
     value_template: >-
                       {% if( (state_attr("sensor.ip13pmsak_geocoded_location", "Zones") | list | length >0) and 
                                          (state_attr("sensor.ip13pmsak_geocoded_location", "Zones")[0], "WBHome")) -%}
                          Sharon is at {{ state_attr("sensor.ip13pmsak_geocoded_location", "Zones")[0] }}
                        {%- else -%}
                          Sharon is at {{ state_attr("sensor.ip13pmsak_geocoded_location", "Locality") }}
                        {%- endif %}

What i am tring to do is show the zone name or the geolocation.locality if not in a defined zone.

Thanks for any guidance

solved it. Put this in my config yaml

sensor:
  - platform: template
    sensors:
      sharon_location:
        friendly_name: "Sharon's Location"
        value_template: >
          {% if (state_attr("sensor.ip13pmsak_geocoded_location", "Zones") | list | length < 1) %}
            Sharon is at {{ state_attr("sensor.ip13pmsak_geocoded_location", "Locality") }}
          {% else %}
            Sharon is at {{ state_attr("sensor.ip13pmsak_geocoded_location", "Zones")[0] }}.
          {% endif %}
      caitlyn_location:
        friendly_name: "Caitlyn's Location"
        value_template: >
          {% if (state_attr("sensor.caitlyn_geocoded_location", "Zones") | list | length < 1) %}
            Caitlyn is at {{ state_attr("sensor.caitlyn_geocoded_location", "Locality") }}
          {% else %}
            Caitlyn is at {{ state_attr("sensor.caitlyn_geocoded_location", "Zones")[0] }}.
          {% endif %}