Auto expand groups with group_expand: true. This helps when your entity or any entity from triggers_update or any discovered entity is a group and you want to update the card also when child entities are updated (eg: counting the number of entities which are on in a group). This works with nested groups too. (Fix #392)
Support for configuring the card size for the auto-layout feature of lovelace using card_size. Default value is still 3, but you can now override it. Lovelace multiplies the value by about 50px for the auto layout feature.
Support for displaying a tooltip while hoovering the card for 1.5s using the tooltip parameter. It supports javascript templates. You can also apply any CSS style to the tooltip (either in the main styles config object or in any of the state entry).
I have been using the Button Card for awhile and just reread the documentation. Iâm amazed at all the new features that have been added - thank you so much! I am now trying to âdeclutterâ my lovelace views by using templates and variables, but have run into the following problem. Iâm sure I am doing something stupid, but âŚ
Iâm simply trying to create a template for a light button.
The variables for v_name and v_icon are overridden as expected, but the variable for v_entity is not. In fact, the default value for v_entity does not even work. Whenever I click on the button I get the following error:
I get this error whether or not I specify the v_entity variable in the lovelace config. Anyone have any ideas? I need to pass the entity as a variable so I can apply some entity specific styles to the template.
That would probably be possible with layout-card. No super easily achievable with button-card if you want to use your interface on different screen sizes.
Could you explain what you mean by âconfiguration overload of just the entityâ, or better yet, point me in the right direction to docs about what this is?
I am trying to add a % label in the template as follows:
label: >
[[[
var b = states['light.fr1'].attributes.brightness;
return parseInt(b ? b/2.55 : '0') + '%';
]]]
Is something like this possible? Is there a way to reference the entity_id from within the template? I saw that the decluttering card can handle this, but am having problems using defaults in variables.
I am expecting a border-radius like i configured it, but in the frontend i get the card without border-radius (or like it was set to 0px).
When i go to turn on the light the border-radius is shown as i set it in the template, but after a refresh it go again to 0px.
This is a screenshot of a light turned on and all the others turned off and all the button use the same template:
How to have the correct border-radius as it was set in the template?
Unfortunately I have been unable to work on HA for some weeks (and that will persist for several more) so all I have been doing is keep my system up to date with HA versions and other custom component updates.
I have just noticed this error but I canât see anything wrong with the code which has always worked in the past. Has anything changed that I missed?
name: >
[[[
if (states['input_boolean.irrigation_master_control_switch'].state == 'off')
return 'SYSTEM IS OFF';
else
...etc...
]]]
reference the entity through entity. I recommend looking at the examples in the docs. This is covered in them under javascript template section. It describes all available built in globals.
The error claims that some states[] entity doesnât exist. Revist all your entities and verify they exist in the system.
FWIW, itâs always best to make sure something exists.
Example, you have:
if (states['group.irrigation_group_cycle1_every_day'].state == 'on' ...
If states[âgroup.irrigation_group_cycle1_every_dayâ] doesnât exist, youâll get an exception. This is whatâs happening. So before you grab states from a potentially non existing object⌠do this:
var my_entity = states['group.irrigation_group_cycle1_every_day'];
if (my_entity && my_entity.state =='on' ...
if my_entity doesnât exist, it will not resolve the second part of the if statement.
Also, when you assign it to a var like that, you can add console.log(my_entity); to verify that these things exist. That will print out info to the area where you saw the exception.
Thank you so much for your help - I think Iâm starting to understand this a little better. If you donât mind, I have one other question: What is the correct syntax to reference the entity variable in the following template excerpt?
label: >
[[[
var b = states['light.fr1'].attributes.brightness;
return parseInt(b ? b/2.55 : '0') + '%';
]]]
where I want to substitute the variable entity in for âlight.fr1â. I tried all sorts of syntax but always get an error. I tried the following but none worked.
var b = states['entity'].attributes.brightness;
var b = states[entity].attributes.brightness;
var b = states[(entity)].attributes.brightness;
var b = states(entity).attributes.brightness;
also, attributes are always strongly typed so brightness is always an int. Also, you should build safety into your system if you accidentally add a entity without brightness or with the wrong entity_id.
If i use it for button cards inside a stack-in-card and all the view is with layout-card the lights doesnât follow some of the options of the template (especially the ones for background card and text options).
Instead, using the same template without stack-card and layout card all is working as expected.
These are some examples.
This is without stack-card and layout card
I have also thought if i created an automation to fill in a text input of the entity name which is playing i could then use the value of the text input as the entity on the button card⌠but im not sure that would work either.
entity still doesnât support templates but you can reference this variable in the other fields like name, label, or any other field which supports javascript templates.
You donât need an entity for the card to work.