Question about variable value

I have the following question:
I have the following code:

Excl: |
{% if trigger.payload == 'on' %} 
{% if Target == 'bathroom_mb' %}
everything|group|sink
{% else %}
' '
{% endif %} 
{% endif %}

This gives the following result:
Excl: everything|group|sink
If I change the code to:

Excl: |
{% if trigger.payload == 'on' %} 
everything|group|
{% if Target == 'bathroom_mb' %}
sink
{% else %}
' '
{% endif %} 
{% endif %}

I get the following result:
Excl: |-
everything|group|

sink

Can I fix this or is what I want not possible?

thanks for any response.

Hello Bart Teuwen,

Try this or a variation. The “-” removes newline characters.

Excl: |
{% if trigger.payload == 'on' -%} 
everything|group|
{%- if Target == 'bathroom_mb' -%}
sink
{% else %}
' '
{% endif %} 
{% endif %}

Thank you very much for your response.
Of course this solves it, should have known but didn’t see it anymore. :unamused: :grimacing: :innocent:

1 Like

Please consider marking my post with the Solution tag. It will automatically place a check-mark 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.
For more information about the Solution tag, refer to guideline 21 in the FAQ.

The topic was not categorised so no solution tag was available. Fixed.