Hello all,
Currently im building my dashboard based on the ui minimalist template. I’m having trouble with the trash collection part. Can anyone help me out?
I use a template for button card called custom_card_trash.yaml with the following code. My dashboard doens’t give out an error but doens’t show anything either. Can anyone find the issue?
---
custom_card_trash:
template:
- "icon_more_info_new"
- "ulm_translation_engine"
variables:
ulm_card_generic_swap_icon: "[[[ return entity.attributes.icon ]]]"
ulm_card_generic_swap_name: "[[[ return entity.attributes.friendly_name ]]]"
ulm_outlet_power_enable_popup: false
custom_fields:
item1:
card:
extra_styles: |
@-webkit-keyframes pulsate-fwd {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
50% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
@keyframes pulsate-fwd {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
50% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
styles:
card:
- animation: >
[[[
if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['sensor.trash_tomorrow'].state == 'today')))
return 'pulsate-fwd 1s ease-in-out infinite';
else
return '';
]]]
type: "custom:button-card"
custom_fields:
item1:
card:
type: "custom:button-card"
entity: "[[[ return entity.entity_id ]]]"
state:
- operator: "template"
value: |
[[[ return states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval'; ]]]
icon: mdi:recycle
styles:
icon:
- color: "rgba(186, 146, 0, 1)"
img_cell:
- background-color: "rgba(186, 146, 0, 0.2)"
# card:
# - animation: >
# [[[
# if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['states['sensor.trash_tomorrow'].state == 'today')))
# return 'blink 3s ease infinite';
# else
# return '';
# ]]]
- operator: "template"
value: |
[[[ return states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons'; ]]]
icon: mdi:delete
styles:
# card:
# - animation: >
# [[[
# if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['states['sensor.trash_tomorrow'].state == 'today')))
# return 'blink 3s ease infinite';
# else
# return '';
# ]]]
icon:
- color: "rgba(160, 160, 160, 1)"
img_cell:
- background-color: "rgba(160, 160, 160, 0.2)"
- operator: "template"
value: |
[[[ return states[entity.entity_id].attributes.message == 'oud papier & karton'; ]]]
icon: mdi:paper-cut-vertical
styles:
icon:
- color: "rgba(0, 100, 200, 1)"
img_cell:
- background-color: "rgba(0, 100, 200, 0.2)"
# card:
# - animation: >
# [[[
# if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['states['sensor.trash_tomorrow'].state == 'today')))
# return 'blink 3s ease infinite';
# else
# return '';
# ]]]
- operator: "template"
value: |
[[[ return states[entity.entity_id].attributes.message == 'grof tuinafval'; ]]]
icon: mdi:paper-cut-vertical
styles:
icon:
- color: "rgba(0, 100, 200, 1)"
img_cell:
- background-color: "rgba(0, 100, 200, 0.2)"
# card:
# - animation: >
# [[[
# if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['states['sensor.trash_tomorrow'].state == 'today')))
# return 'blink 3s ease infinite';
# else
# return '';
# ]]]
- operator: "template"
value: |
[[[ return states[entity.entity_id].attributes.message == 'restafval'; ]]]
icon: mdi:paper-cut-vertical
styles:
icon:
- color: "rgba(0, 100, 200, 1)"
img_cell:
- background-color: "rgba(0, 100, 200, 0.2)"
# card:
# - animation: >
# [[[
# if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['states['sensor.trash_tomorrow'].state == 'today')))
# return 'blink 3s ease infinite';
# else
# return '';
# ]]]
styles:
icon:
- color: "rgba(var(--color-theme),0.3)"
item2:
card:
type: "custom:button-card"
entity: "[[[ return entity.entity_id ]]]"
styles:
name:
- color: >
[[[
if (((states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval') || (states[entity.entity_id].attributes.message == 'plastic, metaal en drankenkartons') || (states[entity.entity_id].attributes.message == 'oud papier & karton')) || (states[entity.entity_id].attributes.message == 'grof tuinafval')) || (states[entity.entity_id].attributes.message == 'restafval')) && ((states['sensor.trash_tomorrow'].state == 'tomorrow') || (states['sensor.trash_tomorrow'].state == 'today')))
return 'rgba(33, 33, 33, 1.0)';
else
return 'rgba(33, 33, 33, 0.4)';
]]]
label: >
[[[
{ return states['sensor.trash_tomorrow'].state; }
]]]
name: >
[[[
if (states[entity.entity_id].attributes.message === 'groente-, fruit- en tuinafval' )
return 'Groente-, fruit- en tuinafval';
if (states[entity.entity_id].attributes.message === 'plastic, metaal en drankenkartons')
return 'plastic, metaal en drankenkartons';
if (states[entity.entity_id].attributes.message === 'oud papier & karton')
return 'oud papier & karton';
if (states[entity.entity_id].attributes.message === 'grof tuinafval')
return 'grof tuinafval';
else
return 'restafval';
]]]
state_display: >
[[[
{ return states['sensor.trash_tomorrow'].state; }
]]]
The code in the dashboard thats using the template is super simple and looks like this:
- type: grid
columns: 2
square: false
view_layout:
grid-area: house
cards:
- type: 'custom:button-card'
template: custom_card_trash
entity: sensor.afvalwijzer_today
the two sensors that are used “sensor.trash_tomorrow” and “sensor.afvalwijzer_today” have the following state.
sensor.trash_tomorrow = tomorrow
sensor.afvalwijzer_today = groente-, fruit- en tuinafval
Does anyone have a suggestion on what I can do to test/debug or fix the code? I already tried multiple variations like this:
Change the code from:
(states[entity.entity_id].attributes.message == 'groente-, fruit- en tuinafval')
to:
(states[entity.entity_id].state == 'groente-, fruit- en tuinafval')
and also removing all different variables back to just the one above but still with no success.
I hope someone can help me out.
Kind regards,
Remco