custom:button-card
is so great - especially the variables
stuff.
In the templates we can configure variables with default values.
If we don’t specify any variable while using the template, the default value is taken.
Up to here common knowledge.
Does anyone know how to explicitly trigger the default value?
I’ve got a template where I have to give variables to an other button-card (a sub-card in a custom_field
):
...
card1:
card:
type: custom:button-card
template: '[[[ return variables.tmpl1 ]]]'
variables:
enty: '[[[ return variables.card1; ]]]'
name: '[[[ return variables.name1; ]]]'
batt: '[[[ return variables.batt1; ]]]'
show: '[[[ if (variables.show1 < 3) return variables.show1; ]]]'
...
The problem lies within the variables.show
of the sub-card: it has a reasonable default, but if I enter a value in variables.show1
of the main card, I want to pass it down.
The way it is written now, something gets passed down to the sub-card, even if the javascript for show
doesn’t return anything - and the default value of the sub-card is ignored since something still gets passed on.
How can I avoid this or check for this something in the sub-card’s template?