custom-cards / button-card

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

Template stopped working after the last HA update #678

Closed CoolS2 closed 1 year ago

CoolS2 commented 1 year ago

Checklist

Describe the bug template stopped working after the last HA update

Version of the card Version: 3.5.0

To Reproduce This is the configuration I used:

button_card_templates:
    button_motion:
      template: button_body
      show_last_changed: true
      tap_action:
        action: more-info
        haptic: light
      hold_action:
        action: more-info
        haptic: success
      state:
       - value: 'off'
         styles:
          icon:
            - color: '#ccc'
          card:
            - filter: opacity(50%)
       - value: 'on'
         styles:
          icon:
            - color: '#40ec5d'

    button_body:
      show_state: false
      show_label: true
      styles:
          img_cell:
            - margin-bottom: 30px
            - margin-top: 10px
            - height: 45px
          name:
            - display: none
          label:
            - font-size: 13px
            - justify-self: start
            - padding: 6px 10px
            - opacity: 0.5

...
              - type: 'custom:button-card'
                entity: sensor.0x00158d0002821a0f_smoke_density
                template: button_motion
                icon: 'mdi:cloud'
                show_state: true
                style: |
                  #state:after {
                    content: '%'
                  }

                styles:
                    state:
                        - font-size: 18px
                    name:
                        - font-size: 14px
                        - margin: 0px 10px 5px 10px
                        - max-width: 90%
                    img_cell:
                        - margin-bottom: 10px
                    custom_fields:
                        signal:
                            - position: absolute
                            - top: 5px
                            - right: 5px
                            - font-size: 13px
                        battery:
                            - position: absolute
                            - top: 5px
                            - left: 5px
                            - font-size: 13px
                state:
                  - operator: '>'
                    value: 60
                    styles:
                          card:
                            - box-shadow: '0px 0px 4px #ff250a'
                          icon:
                            - color: '#ff250a'
                          state:
                            - color: '#ff250a'
                custom_fields:
                    signal: >
                      [[[
                        return `<ha-icon
                          icon="mdi:signal"
                          style="width: 12px; height: 12px; color: #40ec5d;">
                          </ha-icon><span> ${states['sensor.0x00158d0002821a0f_linkquality'].state}</span>`
                      ]]]
                    battery: >
                      [[[
                        return `<ha-icon
                          icon="mdi:battery"
                          style="width: 12px; height: 12px; color: #fff;">
                          </ha-icon><span> ${states['sensor.0x00158d0002821a0f_battery'].state}</span>`
                      ]]]
Mariusthvdb commented 1 year ago

this is rather unclear, we can not go over your complete card config.

please post a minimum config that fails

PetrMedek commented 1 year ago

Same problem: Buttons with template keyword have stopped working. All my pages are affected.

This is simple button: type: custom:button-card template: pv_info entity: sensor.diag_status name: Diagnostika icon: none

This is the error: null is not an object (evaluating 't.config') type: custom:button-card template: pv_info entity: sensor.diag_status name: Diagnostika icon: none

Once I remove the line "template: pv_info" the button will start working. However no formatting is applied of course.

Mariusthvdb commented 1 year ago

Be sure to update to the latest version, this has been fixed in 3.5.0

thomasmaxson commented 1 year ago

I am having the same problem. Updating to v3.5.0 did not solve the problem.

RomRider commented 1 year ago

Check your javascript console: you're probably still running an older version so clear your browser's cache. This is fixed 100% with v3.5.0.

CoolS2 commented 1 year ago

Yes, indeed, I checked in the console. The version was loaded outdated, after I cleared the caches all worked!

samuele2723 commented 1 year ago

Hello, thanks for the confirmation about is solved in 3.5. Any chance cache is also not updated in companion app? I was able to fix template on browser but issue persist on companion

RomRider commented 1 year ago

Same, clear the cache on your companion app. It's still using the old version.

samuele2723 commented 1 year ago

Found. Is under “debug” setting. Thanks Rom