Template issues now

Hi All,
I have try to do a new sensor in HA to convert coordinates, the configuration is valid but the Sensor state is always unavailable .Could you please help me
this is the code

  - platform: template
    sensors:
        latitufede:
          attribute_templates: 
            data: >-
             {% set lat1 = state_attr('sensor.fordpass_gps' , 'latitude') | float %}
             {% set lat2 = state_attr('sensor.fordpass_gps' , 'latitude') | int %}
             {% set baby = ((lat1 – lat2) * 60) | int %}
             {% set pippo = (lat1) | round(1, default=0) | int %}
             {% set pluto = ((lat1 – lat2) * 60) | round(1, default=0) | int %}
             {% set papero = (((((lat1 – lat2) * 60) | round(5, default=0) | float ) - baby)*60) | round(1) %}
             {% test_json4 = {"temp4": pippo,"unit4": "°"} %}
             {% json5 = {"temp5": pluto,"unit5": "'"} %}
             {% json6 = {"temp6": papero,"unit6": "''"} %}
          value_template: >-
              {{ json4.temp4 }}{{ json4.unit4 }}{{ json5.temp5}}{{ json5.unit5 }}{{ json6.temp6}}{{ json6.unit6 }}

First, please edit your post and begin the code section with three backquotes (```) on a blank line and end the code section with matching three backquotes on a blank line…
Thanks!

PS. you can imbed inline code by surrounding it with single backquotes. I like to do it for ‘code’ items I am referencing in my text like switch.bedroom_lights, etc.

On first glance, I do not see a state: entry and I think that might be triggering unavailable

Also, it’s usually best to start a new topic if you cannot find an exact answer, rather than piggybacking on someone else’s post, unless it is strongly related to, or the topic you’re piggybacking on is very general in nature like Alexa Actionable Notifications or Magic Areas, etc… IMO, this should be it’s own post, just my opinion…
:slight_smile:

thanks for the tips

No problem!
You need to add a state value to the entity…

fedesat is using the legacy template sensor format, which uses value_template not state. Adding state to the configuration will not fix anything unless they change everything else as well.

I solved thanks.

Ah, my bad! Sorry.
I fully converted from legacy about 6 mos ago…

Please post your solution so others in future may reference when reading!
I hate when I have read 27 pages of a post and it ends with I figured it out
???

It doesn’t matter if it was a stupid error on your part, just admit it, no shame!
:slight_smile:

This is the working code

sensor:
- platform: template
    sensors:
        longfede:
            value_template: >-
             {% set bedroom = state_attr('sensor.fordpass_gps' , 'longitude') | float %}
             {% set kitchen = state_attr('sensor.fordpass_gps' , 'longitude') | int %}
             {% set baby = ((bedroom - kitchen) * 60) | int %}
             {% set pippo = (bedroom) | round(1, default=0) | int~"°" %}
             {% set pluto = ((bedroom - kitchen) * 60) | round(1, default=0) | int~"'" %}
             {% set papero = (((((bedroom - kitchen) * 60) | round(5, default=0) | float ) - baby)*60) | round(1)~'"' %} 
             {% set json7 = ((pippo )~(pluto)~(papero)) %}
             {{json7}