Is it possible? - Passing complete condition into script variable

Hi!

I am struggling with this situation. I want to pass a complete condition into a script to be evaluated later on this script.

The script which calls the another:

  test_notif_lights_new_prio:
    sequence:
      - service: script.notify_light_new
        data:
          priority_notification: "True"
          condition_stop: 'is_state("input_boolean.notif_lights_auto_alarma_triggered","off")'

and the script which receives the variable condition:

  notify_light_new:
    mode: single
    sequence:  
      - condition: template  
        value_template: '{{ not condition_stop }}'

Is it possible?
Thank you!

No because it will be passed and received as a literal string value.

The Jinja2 interpreter will replace the variable condition_stop with the string value that was passed to the script. That’s all it will do. You’re expecting it to do one more thing and attempt to evaluate the passed string value as a Jinja2 expression.

Nevertheless, I encourage you to try it just in case I am wrong.

Thank you very much for your help @123. It didn’t work.
Finally I have used this solution not as elegant as previously thought:

  test_notif_lights_new_prio:
    sequence:
      - service: script.notify_light_new
        data:
          priority_notification: "True"
          condition_stop: "input_boolean.notif_lights_test_prio,off"

and:

 notify_light_new:
    mode: single
    sequence:  
      - condition: template  
        value_template: "{{ not is_state((condition_stop.split(',')[0]|trim),(condition_stop.split(',')[1]|trim)) }}"

Thank you again!

Unless you have a requirement to pass all the information within a single variable, you can simplify your template by passing it via two variables:

  test_notif_lights_new_prio:
    sequence:
      - service: script.notify_light_new
        data:
          priority_notification: "True"
          entity: "input_boolean.notif_lights_test_prio"
          value: "off"


 notify_light_new:
    mode: single
    sequence:  
      - condition: template  
        value_template: "{{ not is_state(entity, value) }}"

Thank you @123 more clearly and simple with your way.

And following this topic, this script uses more than 10 variables (the code shown previously is just a sample).
Would it be possible to pass the variables in one single line in order to compress the code?. Something like this:

  test_notif_lights_new_prio:
    sequence:
      - service: script.notify_light_new
        data:
          {priority_notification: "True", entity: "input_boolean.notif_lights_test_prio", value: "off" }

You could but I don’t see why you think this is more compressed:

{priority_notification: "True", entity: "input_boolean.notif_lights_test_prio", value: "off" }

than this:

priority_notification: True
entity: input_boolean.notif_lights_test_prio
value: 'off'

The second one is not only easier to read, it uses fewer characters.