I’ve read through the documentation and various posts, but I’m still not clear as to whether or not it’s possible to use templates with triggers_update.
For instance, I have a motion button card template that I’d like to add to my light cards, but also update the motion sensor when that changes, but the light state doesn’t.
In this example I’d move triggers_update to the motion button card template if I can get it to work.
besides all of the above, there are some navigations set in the hold action to paths I use in my config. So you need to adjust those too (or delete that if you don’t want to navigate away)
Don’t get me wrong, but you explain pretty difficult. That’s why I still haven’t figured out how to configure afvalwijzer like I asked you how I wanted it…
this has nothing to do with afvalwijzer perse.
this is nothing more than a button card styling. Wrapped in a template, so I can use these throughout my dashboards
EDIT : So I was so focused on doing this in YML than I didnt think of the obvious, modifying the picture as a png with low alpha Working great, thanks for the addons !
Hello ! is their a way to have a semi-transparent background-image in a template as a container ?
@D34DC3N73R I might be a bit late to the party here, sorry but realised I have a solution for you.
So you aren’t able to use the js templates under the triggers_update property unfortunately, however there is a workaround. If you define a custom field as a card within a button-card template then ALL properties of that card definition can use templates! Not only that but it will still automatically update when it’s entity updates regardless of the state of the parent. That said, I have two other entities that need to update the card in mine so…
You can see in that example that I’m even populating the entity with a js template!
Also all the code for my templates is on Github so feel free to grab anything from there that’ll help. OR better still, load up my templates so you don’t have to redo it yourself. However I completely get it if you already have a whole eco-system going. Just grab the bits you need.
Hope this helps. Let me know if you have any questions about the code.
Unfortunately the problem is not into the quotes. I’m using Raw editor and it automatically removes the quotes and second - name variable works perfectly.
As far as I know you can’t use the entity as a variable (or it’s not meant to at least). Variables are well, variables. So things that you can alter regardless of the entity. Things like name, icon, label etc. Which is why your card shows that error: it can’t return an entity. I believe the templates support the same variable as the javascript template option: GitHub - custom-cards/button-card: ❇️ Lovelace button-card for home assistant.
You need to declare the entity in the card itself, not as a variable. So like this:
I would like to use a button card that displays the state of my window contact sensor and if and only if the window is open, displays the time since it has been opened below the state.
I first tried the show_last_state option but first of all, it displays the information always and not depending on the state and secondly I want to have the format of the output slightly different.
So I tried to realize this using the label of the button card which was successful except the fact that the value was not updated. Is there any way to have the label being refreshed, say every minute?
Here is my button card configuration (I’m using a template as I want to apply this to multiple button cards):
type: custom:button-card
name: Küche
entity: binary_sensor.kitchen_window
icon: mdi:window-closed-variant
template: my_template
button_card_templates:
my_template:
color_type: card
show_name: true
show_icon: true
show_state: true
show_label: true
state:
- id: state_on
value: 'on'
color: var(--accent-color)
label: >
[[[
let diff = Date.now() - new Date(entity.last_changed);
if (diff < 60000)
{
return "Weniger als eine Minute";
}
else if (diff < 3600000)
{
let since = Math.floor(diff / 60000);
return "Seit " + since + " " + ((since == 1) ? "Minute" : "Minuten");
}
else
{
let since = Math.floor(diff / 3600000);
return "Seit " + since + " " + ((since == 1) ? "Stunde" : "Stunden");
}
]]]
- id: state_off
value: 'off'
color: var(--ha-card-background)
Hi,
I’m trying to build a customer button-card template, where I have nested custom:button-card elements and want to use a second template to customize the nested buttons. Is it possible?
note still the triggers_update is still required and it is hard-coded. Button-card uses templates and can not use variables inside those, as it would mean it had to update on all state changes. It did so before, and was taken out because it could bring down the instance… so triggers_update was introduced
Thanks. It looks like - “main” entity - cannot be controlled by variable. This is not a big issue - as it’s easy to add entity with name - instead of variable - as the variable can be used in nested custom:button-card. To give more idea what I’m trying to achieve - I have TADO TVR’s on all my regurgitators - now I want to build a template for card - that can be easily reproduced for all of them - keeping most important parameters visible. So into the template - I’m defining all elements and then into the dashboard / card configuration with just few variables (and entity) - I’m specifying “custom” elements. I want also to add few buttons where I can preform few operations on the TVR - like temp +/- and On/Off. Here is the very draft version of the card (please ignore colors, as I just put few of them to see that they are working, but final design of the card will be on the next stage):