custom-cards / button-card

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

Button loses action, not able to click on it #759

Closed tonyp740613 closed 8 months ago

tonyp740613 commented 1 year ago

Checklist

Describe the bug After upgrading from 3.5.0 to 4.1.1 the button is not able to be used as a button no longer, clicking on the button no longer performs any actions. This happens with version 4.0.0-4.1.1 and reverting to 3.5.0 the button performs the action. Same problem occurs with the Home Assistant Companion app on my phone.

After checking the config of the button I discovered that when I remove the state conditions the action returns to the button.

state:
  - value: Line
    color: cyan
    icon: mdi:transmission-tower
    custom_fields:
      voltage: |
        [[[
          return `<span>${states['sensor.grid_voltage'].state}V<br>${states['sensor.ac_output_active_power'].state}W</span>`
        ]]]
  - value: Battery
    color: lime
    icon: mdi:car-battery
    custom_fields:
      voltage: |
        [[[
          return `<span>${states['sensor.battery_voltage'].state}V<br>${states['sensor.battery_capacity'].state}%<br>${states['sensor.ac_output_active_power'].state}W</span>`
        ]]]

Version of the card Version: 4.0.0 - 4.1.1

To Reproduce This is the configuration I used:

type: custom:button-card
tap_action:
  action: navigate
  navigation_path: /lovelace-inverter/mecer-axpert-inverter
entity: sensor.mode
show_state: false
name: Inverter
styles:
  icon:
    - height: 50px
    - margin-left: 4%
  grid:
    - position: relative
  custom_fields:
    voltage:
      - position: absolute
      - left: 47%
      - top: 10%
      - height: 40px
      - font-size: 12px
      - line-height: 13px
state:
  - value: Line
    color: cyan
    icon: mdi:transmission-tower
    custom_fields:
      voltage: |
        [[[
          return `<span>${states['sensor.grid_voltage'].state}V<br>${states['sensor.ac_output_active_power'].state}W</span>`
        ]]]
  - value: Battery
    color: lime
    icon: mdi:car-battery
    custom_fields:
      voltage: |
        [[[
          return `<span>${states['sensor.battery_voltage'].state}V<br>${states['sensor.battery_capacity'].state}%<br>${states['sensor.ac_output_active_power'].state}W</span>`
        ]]]

Expected behavior When clicking on the button it should perform the action, it no longer does this.

Desktop (please complete the following information):

Smartphone (please complete the following information):

javialmo commented 1 year ago

Hola. es un fallo al poner el custom_fields. eliminalo y vuelve a funcionar...lo que no se el motivo del fallo. un saludo.

ASNNetworks commented 1 year ago

Yes, I can confirm the exact same bug. I also upgraded from 3.5.0 to 4.1.1 and tested everyting from 4.0 and up. All 4.0 and up have this bug. I was bashing my head in, because I have a few button-card templates, and some has broken tap_action and hold_action, while others still worked. All templates however use a shared template that has the tap_action.

I think the bug is caused when using custom_fields inside state condition. Because tap_action worked when entity was off, but once I toggled it on, then tap_action and hold_action didn't work anymore. I have custom_field in state: on condition, but not in state: off condition. So that's why I think this combination is what causes the bug.

But I'm not sure, I reverted back to 3.5.0 because of the headaches lol.

RomRider commented 1 year ago

I'll fix that tomorrow. Sorry folks!

ASNNetworks commented 1 year ago

I'll fix that tomorrow. Sorry folks!

Thanks as always! I updated my post btw, perhaps my findings are of use.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.1.2-dev.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

direx1 commented 1 year ago

Confirmed this is working in 4.1.2-dev.2 but not -dev.3

ASNNetworks commented 1 year ago

Build 4.1.2-dev.1 fixes this indeed. However, I also notice haptic doesn't work properly, seems to be an older bug, which is still present.

https://github.com/custom-cards/button-card/issues/760#issuecomment-1713883095

github-actions[bot] commented 8 months ago

:tada: This issue has been resolved in version 4.1.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: