Button card to toggle lights on/off

I have a button card that turns 2 light modules on/off. The button toggles the lamps, but not its state.

Screen Shot 2025-01-29 at 2.41.38 PM

Button Card…

show_name: true
show_icon: true
type: button
show_state: true
name: Living Room Lamps
icon: mdi:lamps
icon_height: 32px
tap_action:
  action: perform-action
  perform_action: automation.trigger
  target:
    entity_id: automation.living_room_lights_toggle
  data:
    skip_condition: true
entity: input_boolean.living_room_lights

Can a button card NOT perform more than a single action? I’d like to have a trigger AND a toggle.

Automation script…

alias: Living Room Lights (Toggle)
description: ""
triggers: []
conditions: []
actions:
  - if:
      - condition: state
        entity_id: switch.on_off_outlet
        state: "off"
      - condition: device
        type: is_off
        device_id: device_1
        entity_id: entity_1
        domain: switch
    then:
      - type: turn_on
        device_id: device_2
        entity_id: entity_2
        domain: switch

      - type: turn_on
        device_id: device_1
        entity_id: entity_1
        domain: switch
    else:
      - type: turn_off
        device_id: device_2
        entity_id: entity_2
        domain: switch
      - type: turn_off
        device_id: device_1
        entity_id: entity_1
        domain: switch
mode: single

I then tried an input_boolean, but that just toggles the automation enabled/disabled. I’ve been trying t get this sorted for a few days now.

I also tried a button group, that toggles the lights, but also doesn’t update the button state, and only shows the date as the status…

Screen Shot 2025-01-29 at 3.01.16 PM

Here’s how I do it.

  • Go to Settings > Devices & Services > Helpers tab > Create Helper button.
  • Group > Light Group
  • Name it and add the lights you want to group.

Now add the group you created as the entity for a Light Card or Mushroom Light Card.

I had tried that once… does nothing…

Button Card script…

show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
icon: mdi:lamps
show_state: true
icon_height: 32px
entity: button.living_rooom_lights

Screen Shot 2025-01-29 at 3.44.00 PM

Clicking the button card and “press” (in the helper viewer) does seem register in the inspector (just not the lights or the button state)…

Ah! Didn’t realize they were switch/plug entities and not lights.

I think things will start working for you if you convert the switch/plugs to lights.

  • Go to Settings > Devices & Services > Helpers tab > Create Helper button.
  • select Change device type of a switch
  • Choose your switch.
  • Under New Type choose Light

Do that for each plug and then use the new light entity just created like any other light entity.

OMG. Thank you!!! So simple, yet so hard to know what to look for.

That little nugget will go a long way in the future, I had no idea you could change the “type” of a devices.

1 Like

For sure!
One of the keys is to think about what the devices you use are in Home Assistant instead of in the real world. Sometimes the match up, but sometimes they don’t. Once I realized that my google and chatgpt searches got better.