this post was submitted on 28 Sep 2023
21 points (95.7% liked)

homeassistant

12895 readers
46 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 2 years ago
MODERATORS
21
submitted 1 year ago* (last edited 1 year ago) by Otkaz to c/homeassistant
 

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 %}
you are viewing a single comment's thread
view the rest of the comments
[–] Otkaz 1 points 1 year ago (1 children)

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.