piitaya / lovelace-mushroom

Build a beautiful Home Assistant dashboard easily

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Template chips card cannot return 0 when Jinja templating

JesseWebDotCom opened this issue · comments

Current Behavior

In the content field, you cannot return a 0 when Jinja templating but you can with any other number:

- type: custom:mushroom-chips-card
  chips:
    - type: template
      entity: sensor.master_bedroom_lights_on
      content: |
        {{ 0 }}
    - type: template
      entity: sensor.master_bedroom_lights_on
      content: |
        {{ '0' }}
    - type: template
      entity: sensor.master_bedroom_lights_on
      content: |
        {% if 1==1 %}
          0
        {% else %}
          0
        {% endif %}

The code above does not return the expected number (0). It doesn't return at all.

Expected Behavior

I expect the number 0 to be returned. Run the code in the current behavior section but replace "0" with any number and it will return correctly.

Steps To Reproduce

Run the code in the current behavior section and nothing will return.

Environment

Version	core-2022.5.3
Docker	true
Python Version	3.9.5
Operating System Family	Linux
Operating System Version	5.13.0-39-generic
CPU Architecture	x86_64

Anything else?

No response

As a work around (instead of using the letter O), you can use single braces:
{0}

This is true for a lot of fields, and probably due to the fact that 0 is falsey in JS.