Frontend If/Or statement

Hi all,

Always blown away by how helpful everyone is here. I am looking to incorporate an or statement to the following so that I can capture multiple states for a fireTV. I would like to show the source if the firetv is “idle” or “playing” and “Off” if anything else. Not sure how to accomplish with the shorthand if statement syntax.

  - type: template
    entity: media_player.fire_tv_192_168_1_183
    content: >-
      {{ state_attr(entity, 'source') if is_state(entity, 'playing') else
      'FireTV Off' }}
    icon: phu:firetv

Does the template you created not work or are you just looking for a way to do the same thing using iif?

The template above works but need to consider another case other than “playing”.

  - type: template
    entity: media_player.fire_tv_192_168_1_183
    content: >-
      {{ state_attr(entity, 'source') if states(entity) in ['idle', 'playing'] else
      'FireTV Off' }}
    icon: phu:firetv

Perfect, thank you!

1 Like