UI icon indicating copy to clipboard operation
UI copied to clipboard

Custom Waste Collection card not working at all

Open AndLindemann opened this issue 2 years ago • 3 comments

Describe the bug Tried to add the custom paddy_waste_collection card, but it doesn't work at all, throws JS errors in console.

To Reproduce

          - type: "custom:button-card"
            template:
              - custom_card_paddy_waste_collection
            entity: sensor.abfall
            variables:
              ulm_custom_card_paddy_waste_collection_name: paper
              ulm_custom_card_paddy_waste_collection_icon: mdi:trash-can
[Error] anonymous@
_evalTemplate@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:425:73268
@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:425:73761
forEach@[native code]
_getTemplateOrValue@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:425:73726
render@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:425:70749
update@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:1:19902
performUpdate@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:1:16788
@https://..../ui_lovelace_minimalist/cards/button-card/button-card.js:1:16447
asyncFunctionResume@[native code]
@[native code]
promiseReactionJobWithoutPromise@[native code]
promiseReactionJob@[native code]
	render (button-card.js:425:70844)
	update (button-card.js:1:19903)
	performUpdate (button-card.js:1:16789)
	(anonyme Funktion) (button-card.js:1:16448)
	asyncFunctionResume
	(anonyme Funktion)
	promiseReactionJobWithoutPromise
	promiseReactionJob

Expected behavior Waste collection card displayed

Screenshots sensor data

Additional context n/a

AndLindemann avatar Aug 11 '22 09:08 AndLindemann

Somehow it seems the card cannot access the variables:

Bildschirmfoto 2022-08-25 um 16 06 21

Dashboard code:

      - type: custom:button-card
        template: custom_card_paddy_waste_collection
        entity: sensor.abfall
        variables:
          ulm_custom_card_paddy_waste_collection_icon: "mdi:delete"
          ulm_custom_card_paddy_waste_collection_name: "Papier"

Card template code:

---
custom_card_paddy_waste_collection:
  template:
    - "card_generic_swap"
  variables:
    ulm_card_generic_swap_name: "[[[ return variables.ulm_custom_card_paddy_waste_collection_name; ]]]"
    ulm_card_generic_swap_icon: "[[[ return variables.ulm_custom_card_paddy_waste_collection_icon; ]]]"
  state:
    - operator: "template"

Now if I just replace the

  ulm_card_generic_swap_name: "[[[ return variables.ulm_custom_card_paddy_waste_collection_name; ]]]"
   ulm_card_generic_swap_icon: "[[[ return variables.ulm_custom_card_paddy_waste_collection_icon; ]]]"

in the template card with fixed strings, the card works. It can't be too difficult to get the card to properly access the variables, but I wasn't able to figure it out. Any hints? It's probably an easy fix, likely something has changed on how variables are handled since the card was last updated and it just needs some minor corrections to get it back to work?

AndLindemann avatar Aug 25 '22 14:08 AndLindemann

I am having the same issue. Changing the above variables to Strings also fixed it for me.

SgtRootCanal avatar Aug 27 '22 23:08 SgtRootCanal

Seems to be related to https://github.com/UI-Lovelace-Minimalist/UI/pull/783

Slightly different workaround which retains variables:

Card template:

custom_card_paddy_waste_collection:
  template:
    - "card_generic_swap"
  variables:
    ulm_card_generic_swap_name: "[[[ return variables.ulm_card_generic_swap_name ]]]"
    ulm_card_generic_swap_icon: "[[[ return variables.ulm_card_generic_swap_icon ]]]"

Card:

    type: "custom:button-card"
    template: custom_card_paddy_waste_collection
    entity: sensor.waste_collection_household
    variables:
      ulm_card_generic_swap_icon: mdi:delete
      ulm_card_generic_swap_name: Household

rust84 avatar Sep 09 '22 00:09 rust84

I created a pull request to fix this which is similar to @rust84 solution. https://github.com/UI-Lovelace-Minimalist/UI/pull/1107

This has got me up and running again.

jameshirka avatar Nov 30 '22 10:11 jameshirka