Remove the |- Jinja HELP

Im wing this Jiniga stuff

Im Passing some stuff to a script

where: ,office,lounge

in template i see it works

and

happy camper

but when I look at it flow i see

what page of the manual did I miss reading

and other little problem ill like to fix is drop the , at the front of the string.

just want to pass

where: lounge

or

where: lounge,office

not the

where: ,lounge,office

here is my Jinga thing

{% if ',' in where %}
{{ where | replace(",", "\n- notify.alexa_media_") }}
{%else%}
 - notify.alexa_media_{{where}}
{% endif %}

Jinja. Not Jinga.

|- is yaml not jinja. Try out the demo here: https://yaml-multiline.info/

thanks bro look like more reading

can’t work it out

yelling at the screen not working :frowning:

but work out how to drop the leading ,

          {%- if ',' in where %}
            - notify.alexa_media_{{ where | replace(",", "\n- notify.alexa_media_") }}
          {%-else%}
            - notify.alexa_media_{{where}}
          {% endif %}

Pass this instead:

where:
  - 'lounge'
  - 'office'

Or

where:
  - 'lounge'

Then use this:

entity_id: >
  {% if where|count == 2 %}
    - notify.alexa_media_{{where[0]}}
    - notify.alexa_media_{{where[1]}}
  {% else %}
    - notify.alexa_media_{{where[0]}}
  {% endif %}
1 Like

thanks bro