custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

tap_action executed despite being in lock state #688

Closed arifroni closed 1 year ago

arifroni commented 1 year ago

Checklist

Describe the bug When I press the button, whether it is locked or not locked, tap_action executes.

Version of the card Version: 3.5

To Reproduce This is the configuration I used:

- type: custom:button-card
  entity: sensor.deebot_kajer_beti_ronbot_queue
  icon: mdi:play-pause
  name: '[[[ if (entity.state === "") return "Select Rooms"; else return "Start Clean" ]]]'
  aspect_ratio: 2.6/1
  triggers_update: 
    - vacuum.kajer_beti_ronbot
  lock:
    enabled: |
      [[[ 
        return !entity.state || 
          entity.state.length === 0 ||
          states['vacuum.kajer_beti_ronbot'].state !== 'docked'
      ]]]
    exemptions: []
  tap_action:
    action: call-service
    # service: script.deebot_clean
    service: notify.persistent_notification
    service_data:
      message: msg
      title: title
  styles:
    icon:
      - width: 1.8em
    card:
      - color: var(--disabled-text-color)
    lock:
      - color: var(--primary-text-color)
      - width: 2em
  state:
    - operator: template
      value: |
        [[[ return states['vacuum.kajer_beti_ronbot'].state === 'returning' ]]]
      name: Returning...
      icon: mdi:toilet
      spin: true
    - operator: template
      value: |
        [[[ return states['vacuum.kajer_beti_ronbot'].state !== 'docked' ]]]
      name: Cleaning...
      icon: mdi:cog
      spin: true
    - operator: template
      value: |
        [[[ return (entity.state || entity.state.length > 0) ]]]
      styles:
        card:
          - color: var(--text-color)
        icon:
          - color: var(--text-color)

Screenshots msedge_2023-04-26_15-33-48

Expected behavior When the icon is locked, i expect nothing happens when i click the button

Desktop (please complete the following information):

Home Assistant 2023.5.2 Supervisor 2023.04.1 Operating System 10.1 Frontend 20230503.3 - latest

ASNNetworks commented 1 year ago

Perhaps bug is associated because you also have

    exemptions: []

Allthough it's empty, perhaps that's what causes he bug to exempt everything? Try it with that part removed. I have latest button-card and never had this issue, have multiple locked buttons.

Also good to state the HA version you are using. Could also be a HA frontend change that breaks it.

arifroni commented 1 year ago

Perhaps bug is associated because you also have

    exemptions: []

Allthough it's empty, perhaps that's what causes he bug to exempt everything? Try it with that part removed. I have latest button-card and never had this issue, have multiple locked buttons.

Also good to state the HA version you are using. Could also be a HA frontend change that breaks it.

Tried without the exemptions part, didn't work. Added the HA version.

For me, it was also working fine. not sure when it got broken :(

ASNNetworks commented 1 year ago

Perhaps bug is associated because you also have

    exemptions: []

Allthough it's empty, perhaps that's what causes he bug to exempt everything? Try it with that part removed. I have latest button-card and never had this issue, have multiple locked buttons. Also good to state the HA version you are using. Could also be a HA frontend change that breaks it.

Tried without the exemptions part, didn't work. Added the HA version.

For me, it was also working fine. not sure when it got broken :(

Seeing as how you're running HA 2023.5.2, most likely that's where it got broken. Sadly the frontend update that came with 2023.5.x has broken multiple things, like z-index. Which causes the lock to show above popups and dialogs now as well. Chances are this also broke the way the lock functions, since the z-index has changed.

I updated to 2023.5.2 yesterday and after seeing the z-index issues with browser_mod and button-card I reverted to 2023.4.6 for the time being.

ktownsend-personal commented 1 year ago

Sadly the frontend update that came with 2023.5.x has broken multiple things, like z-index. Which causes the lock to show above popups and dialogs now as well. Chances are this also broke the way the lock functions, since the z-index has changed.

I did some digging with the browser debug window and determined that there was a crucial css variable missing in my theme to ensure a proper z-index of the dialog.

I added this to my theme:

      dialog-z-index: 100
      mdc-dialog-z-index: 100

The first one is what did it, but both were missing.

RomRider commented 1 year ago

Could you please try the latest beta? I can't seem to reproduce with it.

arifroni commented 1 year ago

I am with the latest version 3.5.0. I removed the lock icon style. and now it is working fine. I am unsure whether it relates to browser mod or some other modules.