Hide Buttons when a switch is off

Hey Everyone,

I would like help in being able to hide 3 buttons when a switch is on, below is a screengrab of what i have.

The Shutdown, Hibernate and Restart buttons are all useless if my PC is already off so i’d like to hide these when the switch (ryzen at the top) is off

This is currently a vertical stack card and the a horizontal stack card for the buttons if that matters.

Thanks

You could use conditional cards, or even better:

Awesome, thanks :slight_smile:

@DTMHibbert did you find a suitable solution for this?

Also curious what you’re running to get the button/how it was made. It looks awesome and I’d like to integrate something like that to control some VMs I have.

Hey,

Yep, i settled with the conditional card, little tricky to setup i was a noob with YAML back then im a bit better now.

hopefully my code below will help.

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: switch.ryzen
      - entity: sensor.ryzen3900x_cpu_usage
        name: CPU Usage
      - entity: sensor.ryzen3900x_memory_usage
        name: RAM Usage
      - entity: sensor.ryzen3900x_storage_c_usage
        name: C:/ Drive Usage
      - entity: sensor.ryzen3900x_storage_f_usage
        name: F:/ Drive Usage
      - entity: sensor.ryzen3900x_system_uptime
        name: Uptime
      - entity: sensor.ryzen3900x_system_idle_time
        name: Idle Time
    title: Ryzen
  - type: conditional
    conditions:
      - entity: switch.ryzen
        state: 'on'
    card:
      type: horizontal-stack
      cards:
        - type: button
          entity: script.shutdown
          name: Shutdown
          icon: ios:poweroff
          tap_action:
            action: call-service
            service: script.shutdown
            service_data: {}
            target: {}
        - type: button
          entity: script.hibernate
          name: Hibernate
          icon: ios:sleep
          tap_action:
            action: call-service
            service: script.hibernate
            service_data: {}
            target: {}
        - type: button
          entity: script.restart
          name: Restart
          show_state: false
          show_icon: true
          icon: ios:restart
          tap_action:
            action: call-service
            service: script.restart
            service_data: {}
            target: {}

Let me know if you have any problems.

Thanks