Nested IF to display different states on a button

Hello.

I am not well versed on YAML and I have spent 2 days searching for answers to this most likely simple question.

I have a button that displays the state of an Usenet article downloader, SABnzbd.
It can have different states, from Paused, Idle, and Downloading.
The YAML code I have can display 2 states, but how can I make it to display 3 or more states?

This is the simple code I have now:

type: custom:mushroom-template-badge
content: |-
  {% if is_state('sensor.sabnzbd_status', 'Idle') %}
    Idle
  {% else %}
    Downloading
  {% endif %}
icon: mdi:download-box
color: ""
picture: https://image.pngaaa.com/63/5220063-middle.png
label: SABnzbd
tap_action:
  action: url
  url_path: http://192.168.8.129:9292/

Thank you for any assistance.

Just add as many {% elif ... %} statements you want.

In the future, consult the Jinja documentation:

https://jinja.palletsprojects.com/en/stable/templates/#if

But if all you want is to output the state of the sensor, just do this:

{{ states('sensor.sabnzbd_status') }}
1 Like