Good day all,
I am trying to get a mushroom chip card to display the value 0 in the chip where I am showing the number of lights on in the house.
The number of lights on is computed in a template sensor in my configuration.yaml as follows:
template:
- sensor:
- name: "Number of Lights On"
unique_id: "XYZ-103"
state: |
{{ states.light
| rejectattr('attributes.entity_id', 'defined')
| selectattr('state', 'eq', 'on')
| list | count }}
The chip card is configured as follows on my dashboard:
- type: template
entity: sensor.number_of_lights_on
icon: |-
{% if states(entity)|int > 0 %}
mdi:lightbulb-on
{% else %}
mdi:lightbulb-outline
{% endif %}
icon_color: |-
{% if states(entity)|int > 0 %}
yellow
{% else %}
gray
{% endif %}
content: |-
{% if states(entity)|int > 0 %}
{{ states(entity) }}
{% else %}
0
{% endif %}
alignment: center
I am at a loss as to what to do here. Just using {{ states(enitity) }} does not show the zero. The if statement above will only show zero in the chip card if I put quotes around it and then it shows the quotes.
Any help would be appreciated. Thanks in advance.