Conditional

Hi, i want an tap action with conditional data so i can execute a service with different values!.
The service does work when i execute it without condition.
I can use some help with the condition, because it gives an error…
the error shows up in the screen and disappears…

error:
(possible options: selecteer, opstarten, afsluiten)

code

                    tap_action:
                      action: call-service
                      service: input_select.select_option
                      data:
                        option: |-
                          {% if (entity.state == 'Verbonden') %}                          
                              afsluiten
                          {% else %}
                              opstarten
            		  {% endif %}
                      target:
                        entity_id: input_select.nastypen

i also tried, also no luck

                        option: |-
                          [[[
                            if (entity.state == 'Verbonden') 
                              return "afsluiten";
                            else 
                              return "opstarten";
                          ]]]                        

image

Rather than using a condition in the tap action, use the condition to display one of two buttons (or whatever you’re using) with different tap actions.

ok, i will call a script…
Is it allowed to call the script with variable data like {{entity.state}} ?

It is not possible to use templates for actions.

If it has {{ ... }} it is a template, so no.

See my other idea: conditional view of two apparently-identical widgets with different actions.

ahhh, still learning :slight_smile:
no problem will check it in the script…