custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

A tap_action question. #616

Open Opontios opened 2 years ago

Opontios commented 2 years ago

Don't know if it's been already answered, but is it possible to define 2 different actions under tap_action, as 2 different call services? I tried any possible way that I could, but it isn't validated by the card editor. Thanks.

Wombosvideo commented 2 years ago

This is what scripts are for. The example below gives you a button to perform actions for when you are not at home, like turning off the lights and the thermostat.

Card config:

type: custom:button-card
name: Not at home
tap_action:
  action: call-service
  service: script.not_at_home_actions

Script:

alias: Not at home actions
icon: mdi:script
mode: single
sequence:
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.luca
  - service: climate.turn_off
    data: {}
    target:
      entity_id: climate.luca_thermostat
Opontios commented 2 years ago

I'm aware about the scripts. I wanted to know if it was possible to send 2 different service calls in the card config.

JayChun commented 2 years ago

I'm aware about the scripts. I wanted to know if it was possible to send 2 different service calls in the card config.

I think you need 'multi_calls', please see in my question body. (https://github.com/custom-cards/button-card/issues/620#issue-1387396576)