Value Template - Display values that do not exist

Hello,

I am working with new Spot Crime sensor. I want to create separate entries for all possible attributes:

Arrest
Arson
Assault
Burglary
Robbery
Shooting
Theft
Vandalism
Other

It kinda works… If there is a value, I can see it, but if there is no value, it does not show anything. Nothing. Just empty space.

I want it to show 0 instead of the empty space, but I cannot do it.I tried this:

      crime_in_the_area_arrest:
        friendly_name: 'Arrest'
        value_template: >-
          {% if states('sensor.crime_in_the_area.attributes.arrest') | float > 0 %}
            {{ states.sensor.crime_in_the_area.attributes.arrest }}
          {% else %}
            0
          {% endif %}

and this:

      crime_in_the_area_assault:
        friendly_name: 'Assault'
        value_template: >-
          {% if states('sensor.crime_in_the_area.attributes.assault')|float>0 %}
            {{ states.sensor.crime_in_the_area.attributes.assault }}
          {% else %}
            0
          {% endif %}

and this:

      crime_in_the_area_burglary:
        friendly_name: 'Burglary'
        value_template: >-
          {%- if states.sensor.crime_in_the_area -%}
            {{ states.sensor.crime_in_the_area.attributes.burglary }}
          {%- else -%}
            0
          {%- endif -%}

Can someone help me with this?

Are there any errors in your logs ?
You’re saying some of the sensors have no value, yet you’re trying to compare that no value to a value (>0)
No value does not equal 0.

Maybe your template should read

{% if states('sensor.crime_in_the_area.attributes.arrest') =="" %}
    0
{% else %}
   {{ states.sensor.crime_in_the_area.attributes.arrest }}
{% endif %}

My indenting may be off as I’m on my mobile.

It was a good suggestion, but it does not work.

There are no any errors related to this sensor.