Locking button state based on condition of another device

I have a particular scenario where I’m using a relay switch to change the energy supply to an air conditioning unit. In my scenario I would like to block ability to toggle the switch when the AC unit is running. Is there a way to grey-out or lock state of a switch/button based on an external condition to achieve that?

Or should I just skip buttons altogether and use automatons and button helpers to control the state of each relay, without exposing the direct relay switch to the dashboard, to avoid any accidental toggles during AC operation?

thanks, this is a great example - I tried using it before, but “condition” option comes with zero examples and it took me a while to figure it out…

but it is simple and does exactly what I need:

show_name: true
show_icon: true
type: custom:restriction-card
restrictions:
  block: true
condition: 
  entity: climate.bedroom
  value: cool
card:
  type: button
  name: Bedroom AC Solar
  entity: switch.sonoff_10015127ce
  tap_action:
    action: toggle
1 Like