{{ '<br> *** # Bewegung' if x | length > 0 else '' }}
If the length of the variable x is greater than zero it will display *** # Bewegung on a new line, otherwise it will display nothing in the Markdown Card. If you want *** on one line and #Bewugung on a second line, use this:
{{ '<br> *** <br> # Bewegung' if x | length > 0 else '' }}
Here’s a screenshot of the result:
I provided an example of how to do it in my previous post.
As you can see in your screenshot, the *** # is displayed with this code. Normally in Markdown a line is displayed with *** and with # the word behind it is printed in large letters.
That’s good news. Please consider marking my post above with the Solution tag. It will automatically place a checkmark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
{% 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 %}
{% if x | length > 0 %}
***
# Bewegung
{% else %}
{% set x = expand(
'sensor.netatmo_haus_buro_og_wohnzimmer_og_co2',
'sensor.netatmo_haus_buro_og_schlafzimmer_og_co2',
'sensor.netatmo_haus_buro_og_bad_og_co2',
'sensor.netatmo_haus_buro_og_co2',
'sensor.netatmo_haus_buro_anbau_oben_co2',
'sensor.netatmo_haus_buro_wohnzimmer_co2',
'sensor.netatmo_haus_buro_schlafzimmer_co2',
'sensor.netatmo_haus_buro_co2'
)
| selectattr('state', 'gt', 1000)
| map(attribute='name') | list %}
{% if x | length > 0 %}
***
# Luftqualität
{% endif %}
{% endif %}