#Checking variable value for If-Then in automation

1 messages · Page 1 of 1 (latest)

vernal reef
#

Hi all, I'm working on an LLM Vision automation to only send a notification when something is found. My AI prompt says to return "Ignore" if the specified condition isn't met, then I'm trying to send a notification ONLY if the response is NOT "Ignore" but I can't seem to get the value template correct.

I'm currently having it notify in both cases (with differing titles) for testing.

- if:
      - condition: template
        value_template: >-
          "{{ response.response_text == 'Ignore' }}"
    then:
      - action: notify.******
        metadata: {}
        data:
          message: Ignore This
          title: Ignore This
    else:
      - action: notify.*****
        metadata: {}
        data:
          message: "{{response.response_text}}"
          title: Something found
          data: {}
tranquil orchid
#

AFAIK you either need quotes around templates, or a multiline string character, but not both.

        value_template: >-
          "{{ response.response_text == 'Ignore' }}"
#

I think maybe this is more correct?

        value_template: >-
          {{ response.response_text == 'Ignore' }}
#

Not sure if that's your issue or not.

vernal reef
# tranquil orchid I think maybe this is more correct? ``` value_template: >- {{ ...

Thanks for the response. I've tried a few different syntaxes all with no success. I've switched to what you have, and still not yielding what I would expect.

What's funny, is it's finding the value_template false, but returning a message of "Ignore" in a "Something Found" message, so response.response_text is definitely populated properly, but there's an issue with the comparison boolean.

#

screenshot from the trace (the extra quotes were added there and not present in the actual code)

bitter quest
#

How sure are you that the response is 'Ignore' not 'ignore'?

vernal reef
#

100%. I have it send me the response in a message, so I was able to confirm. Checked for an extra space even. I did manage to get it to work by using "in" instead of a straight comparison.

I ended up going about it a different way (though a bit hacky). Rather than having it prompt "Ignore," I have it prepend "[person]" and "[vehicle]" when those things are detected. Then I only run the automation when those codes are in the response
i.e.:

{{ '[person]' in response.response_text }}