lovelace-paper-buttons-row icon indicating copy to clipboard operation
lovelace-paper-buttons-row copied to clipboard

Templating tap_action

Open fusionstream opened this issue 3 years ago • 3 comments
trafficstars

I'm trying to template a tap_action to run different scripts based on the state of an entity

      - type: custom:paper-buttons-row
        buttons:
          - entity: input_boolean.ac_fan_dryout_running
            icon: mdi:hair-dryer
            layout: icon|state
            tap_action:
              action: call-service
              service_data: {}
              target: {}
              service: >
                {% if is_state('input_boolean.ac_fan_dryout_running',
                'off') %}
                  script.s_room_ac_fan_dryout_begin
                {% else %}
                  script.s_room_ac_fan_dryout_cancel
                {% endif %}
            state_styles:
              'on':
                color: green
              'off':
                color: red
            state_text:
              'on': Cancel Dryout Sequence
              'off': Begin Dryout Sequence

The error I get is "Failed to call service {% if is_state('input_boolean.ac_fan_dryout_running', 'off') %}"

Would this mean this feature is not implemented yet?

fusionstream avatar Jan 04 '22 16:01 fusionstream

Yeah currently no part of the actions can be templated. It's a cool idea though so maybe in the future.

jcwillox avatar Jan 05 '22 02:01 jcwillox

Ok thank you. No worries.

For anyone needing a fast solution, one workaround is to toggle a separate input boolean via the tap-action and running automations on that input boolean's state.

Another workaround and the one I'm going for, is to use 2 conditional cards to contain alternate versions of these button rows.

fusionstream avatar Jan 05 '22 03:01 fusionstream