I'm trying to get a script built. I want to check if a variable exist and include it if it does. Just really struggling to figure out the formatting. Something like

script:
  sequence:
    target:
      entity_id: "{{ entity }}"
    {% if variable is defined %}
      data: "{{ variable }}"
    {% endif %}
  • nottelling@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    This looks like the right answer, since OP's jinja is correct.

    OP, you can go to developer tools to test your template syntax against the live data in HA.