button-card icon indicating copy to clipboard operation
button-card copied to clipboard

Add Tap-Action to States for conditional actions

Open UniqueName992 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like Have the ability to define different tap-actions for each state of the button in the YAML

Describe alternatives you've considered Using Scripts with conditional checks, however I'd like to have conditional confirmation/lockout depending on the state and avoid extra scripts Using different actions (tap / double tap etc.) for each service call, however it's not as intuitive for the end user Using a binary toggle, however it doesn't provide monitoring feedback of status

Additional context For a server on/off button. State provided by ping, shutdown by SSH and power on by smart switch / WoL (if it works). Providing both actions and state monitoring (red/green indicator) on a button is very intuitive for the user (and cool)

An example configuration YAML could be:

type: custom:button-card
icon: mdi:power
entity: binary_sensor.ping_server
show_name: false
state:
  - value: 'on'
    tap_action:
      action: call-service
      service: shell_command.server_shutdown
      confirmation:
        text: Power down server?
    styles:
      icon:
        - color: green
  - value: 'off'
    tap_action:
      action: call-service
      service: (Wol / switch)
    styles:
      icon:
        - color: red

Thank you for the amazing mod!

UniqueName992 avatar Jan 07 '22 02:01 UniqueName992

This would be great, was just searching for this and only find the templating solution.

AndyVRD avatar Jan 14 '22 19:01 AndyVRD

+1 for this idea!

ghost avatar May 03 '22 12:05 ghost