Disable or Lock Lovelace Button or Switch

I am looking for a Button and Switch card that can be disabled or locked. The ideal behavior would be for the Card to display a lock icon when locked and, when touched, do nothing. In my case, the lock state of the Card would be driven by automation.

My use case:

I would like to have a Button that will open or close a garage door. This Button would be locked when my alarm is set. I would have a sensor or state (sorry, newbie to HA) called something like Lock_Garage_Biutton, which would be true when the alarm is armed and the garage door is closed. When the alarm is disarmed, Lock_Garage_Button woulkd become false. When Lock_Garage_Button is true, the lock icon would display on the Button and the Button would be inactive. Otherwise, the lock icon would be hidden and the Button would work as usual.

I know that I can use an automation to prevent the button from doing anything when the alarm is set, but this is not a good user experience as it is not clear to the user that the button has been disabled.

I have looked at the Button Card on Awesome-HA and available thru HACS, but it appears that touching the button of this card changes the lock state.

Any suggestions would be helpful.

There is this one:

but I don’t think it can be controlled via an automation. It would be cool if I was wrong… :slightly_smiling_face:

Thank you, @finity. I will check this out over the next few days. If I can disable simply by using the alarm sensor being disarmed, that would work well.

Thank you again.

1 Like

@finity, this turns out to be exactly what I am looking for. Using the YAML below, I am able to disable or enable the garage door button based on the state of the alarm. No automation needed. And it even pops up an alert to tell the user why the button is disabled!

    restrictions:
      block:
        text: Disarm alarm to enable the garage door button.
        condition:
          value: disarmed
          entity: alarm_control_panel.main
          operator: '!='

Thank you again for your help with this.

2 Likes