Using template trigger in conditions in scripts

Hi everyone,

I am trying to do the following and have this for 90% working but I need a little help for the final 10%.
I have a button (button-card) the calls via the tap_action a script.

tap_action:
  action: call-service
  service: script.sidebar_light
  service_data:
    entity_id: '[[[ return entity.entity_id ]]]'

The script is

sidebar_light:
  mode: restart
  sequence:
  - service: light.toggle
    data_template:
      entity_id: '{{ entity_id }}'
  - condition: template
    value_template: "{{ trigger.entity_id.state ==  'on' }}"
  - service: input_select.select_option
    data_template:
      entity_id: input_select.sidebar_light
      option: '{{ entity_id }}'
  - delay: '10'
  - service: input_select.select_option
    data:
      entity_id: input_select.sidebar_light
      option: info

This setup works like I want it to (almost).
It toggles the light ON en sets the input_select correctly. This then changes a entities card on the HA Frontend via state-switch and shows me the brightness/temp/color controls for the toggled light. This then changes back to its default card after 10 seconds.
Now I can’t get the condition part working. Because I do not want to run the input_select.select_option part of the script when I turn OFF the light.
I’ve tried various ways to write the condition but none work.

Thanks in advance.

Mike

Do I understand correctly, that the entity_id you are passing to the script is also the entity_id of the entity that should be checked in the condition? If so, this should work:

- condition: template
  value_template: "{{ is_state(entity_id, 'on' }}"
1 Like

Hi Burningstone,

I tried a lot of different ways but not yours.
Thanks! it works now!

only the ) was missing after ‘on’.
It took me a while to notice it.