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 %}
  • @bob_wiley
    link
    English
    3
    edit-2
    11 months ago

    deleted by creator

    • @OtkazOP
      link
      English
      11 year ago

      It worked the same as your suggestion above. In cases the variable is used it does works as intended but in the situation the variable is not set it’s still sending data: just with a blank value.

      • @bob_wiley
        link
        English
        1
        edit-2
        11 months ago

        deleted by creator

        • @OtkazOP
          link
          English
          11 year ago

          When I tried playing with omit in the template editor I got an error about omit being undefined so probably not built in. Bummer because that would be a very elegant solution to this. I’m going to put this down for the night and try picking it back up tomorrow. I really appreciate all the suggestions. Hopefully it will lead me to a solution.

          • @bob_wiley
            link
            English
            1
            edit-2
            11 months ago

            deleted by creator