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?