this post was submitted on 28 Sep 2023
20 points (95.5% liked)

homeassistant

12102 readers
22 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 1 year ago
MODERATORS
 

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@lemmy.world 1 points 1 year ago (1 children)

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.