Titel only if one of many entities on

Hello,
I would like to put an titel on my dashboard, but only if one of many entities is on.

At the moment I have it with the following code:

type: custom:mushroom-title-card
title: |-
  {% set x = expand(
    'binary_sensor.flur_bewegungssensor_motion',  'binary_sensor.bad_bewegungssensor_motion',  'binary_sensor.kuche_bewegunssensor_motion', 'binary_sensor.schlafzimmer_bewegungssensor_motion', 'binary_sensor.homematicip_bewegungsmelder_innen'

    )
       | selectattr('state', 'eq', 'on')
       | map(attribute='name') | list %}
    {{  'Bewegung' if x | length > 0 else '' }}


The text “Bewegung” only displayed if one of the entities is on. That works. But if no entity is on, I get a placeholder displayed:

What code do I have to use so that the entire line is not displayed?

You should ask in the “Mushroom” thread, as this is a custom-card. :slight_smile:

Ah sorry, now I have Post in the mushroom threat.

1 Like