custom-cards / decluttering-card

🧹 Declutter your lovelace configuration with the help of this card
MIT License
372 stars 30 forks source link

e.slice is not a function #77

Closed PrestonMcAfee closed 7 months ago

PrestonMcAfee commented 7 months ago

I'm a newbie at HA but code in python, mathematica and javascript regularly. Sorry if I've made a rookie mistake.

I installed decluttering-card via HACS and it shows in the list of resources. I get a javascript error: e.slice is not a function.

I've tried various things, like making a hello world simple declutter, removing and installing 0.6.3.

Checklist:

Release with the issue: both 0.6.3 and1.0.0

Last working release (if known): N/A

Browser and Operating System: Chrome 121.0.6167.185 running on Windows 11 23H2.

Description of problem:

custom:decluttering-card produces javascript errors and does not run. I added it with HACS, and it shows in the list of resources along with other HACS cards. My decluttering template is

decluttering_templates:
  menu:
    card:
      type: custom:button-card
      name: '[[name]]'
      icon: mdi:'[[icon]]'
      tap_action:
        action: call-service
        service: script.togr
        service_data:
          room: '[[room]]'
      styles:
        icon:
          - color: |
              [[[ if (states['[[room]]'].state == 'on') 
                  return "#FF00FF";
                else return "var(--primary-text-color)";  ]]]

which I put at the top of the dashboard using the raw configuration editor. I then created this card:

type: custom:decluttering-card
template: menu
variables:
  name: Lights
  icon: home-floor-3
  room: input_boolean.r3

which produces the error. There is no error if the card is not present, perhaps because decluttering-card.js isn't called.

Javascript errors shown in the web inspector (if applicable):

create-element-base.ts:180 card custom:decluttering-card TypeError: e.slice is not a function
    at decluttering-card.js?hacstag=188686483100:190:1654
    at ke.setConfig (decluttering-card.js?hacstag=188686483100:190:2127)
    at r (create-element-base.ts:95:11)
    at create-element-base.ts:109:12
    at h (create-element-base.ts:213:12)
    at c (create-element-base.ts:170:12)
    at g (create-card-element.ts:101:3)
    at i.value (hui-view.ts:66:21)
    at i.value (hui-view.ts:304:26)
    at t.addEventListener.once (hui-view.ts:80:16)

Additional information: I also put this to the community here.

ildar170975 commented 7 months ago

Answered in community.

PrestonMcAfee commented 7 months ago

As ildar notes, solution was that I hadn't used a list for the configuration

type: custom:decluttering-card
template: menu
variables:
  - name: Lights
  - icon: home-floor-3
  - room: input_boolean.r3
PrestonMcAfee commented 7 months ago

Closing as solved