One button with two actions

Hello, I am trying to create a button to do two actions at the same time with one button (i.e. turn on my left and right speakers), so I created, which is not working:

type: button
tap_action:
action: toggle
entities:

  • switch.office_guest_bed_rm_speakers_switch_4
  • switch.office_guest_bed_rm_speakers_switch_3
    show_name: true
    show_icon: true
    icon: mdi:volume-high
    state: true
  • value: on
    color: lawngreen
  • value: off
    color: grey
    name: Office Speakers

Thank you!

You have to use ‘call service’\toggle and then choose you entities. For the start

type: button
tap_action:
  action: call-service
  service: switch.toggle
  service_data: {}
  target:
    entity_id:
      - switch.office_guest_bed_rm_speakers_switch_4
      - switch.office_guest_bed_rm_speakers_switch_3
entity: ''
show_state: true
icon: mdi:volume-high
name: Office Speakers

Some reading for you as you will want more stuff sooner or later :slight_smile: :

And have a look at this advice:

1 Like

Thank you, soooooo much! I have been trying to create this for 3 days with no luck, and that works!

In addition, how would I create the color to change when turning the button on or off? Right now I have, and it doesn’t work:

type: button
tap_action:
action: call-service
service: switch.toggle
service_data: {}
target:
entity_id:
- switch.office_guest_bed_rm_speakers_switch_4
- switch.office_guest_bed_rm_speakers_switch_3
entity: ‘’
show_state: true
state:

  • value: ‘on’
    color: lawngreen
  • value: ‘off’
    color: grey
    icon: mdi:volume-high
    name: Office Speakers

Thank you so much again for your help. I am not a programmer, nor do I have any formal training in this area, but I am slowly learning how to do this in HA.

Happy I could help as I got no programming background myself. :wink:

Changing the icon color to your needs won’t work in a regular button card that is why I added the reading list above, esp. the custom:button-card.
You would have to use a template for the icon_color which the regular button-card is not capable of.

And three more things:

  1. Please use the code-tags as in the link with the “How to help us help you”.
  2. Would be cool if you mark my answer as the solution.
  3. More to read to understand about changing things the way you want them: Templating - Home Assistant
1 Like

Thank you!

1 Like