New in home assistant. Trying to do garbage collection (https://github.com/bruxy70/Garbage-Collection) and can not get the the days left to display. Wonder if anyone would know what I’m doing wrong. If I go to developer tools-templates I can see the correct data but they will now show on the png.
Would you be able to post the config of the card as text (formatted as a code block) rather than an image? I think you need populate the entities collection for the outer card-templater card, but it’s hard to tell from an image.
this is pseudocode to signify what I want to achieve (albeit I tried this precise code too, I tried many different combinations using states. and many more, but can’t figure what’s wrong
Thank you… that was embarassingly simple!
I am not sure why I cannot add something like sensor.hifi_title_status.split(‘,’)[0] tho … it works in the templates tester
it does working with this code tho
'{% set now_playing = states.sensor.hifi_title_status.state_with_unit.split(",")[0] %}
{{ now_playing }}'
that’s good I guess
Any idea why mini-media-player refreshes much slower when passed through card-templater?
I have 2 cards right now, one with mini-media-player only, and one with mini-media-player inside card-templater.
I can take an action on either card (change source, volume,etc) and it will always show the updated value on the mini-media-player only one within a very few seconds, while the one inside card-templater takes several, like 30 seconds or so.
@Steven_Rollason Thanks for writing and supporting this - great work!
Is there any way to use wildcards in templates? I have a lot of NMap-Tracker entities that show up as device trackers, but I just want to show if they are connected to the network - Home/Away isn’t really appropriate.
Here’s what I have so far - I really want to avoid having to cut and paste the template for 50+ devices:
There’s nothing built-in for this, but you could use this card together with the auto-entities card to do it.
The best way to use it would be to add all those device_trackers to a group called group.nmap_trackers and then the configuration would look like this:
If you don’t define the entities option on the card you are templating with card-templater, then card-templater will pass its entities option (which, in turn, it is getting from auto-entities) on to it.
auto-entities will automatically replace the text this.entity_id with the entity id of each entity, so states.this.entity_id.state becomes states.device_tracker.whatever.state if the matching entity is device_tracker.whatever for example.
However, a template always actually returns a string (this is a limitation of templates, not specific to this card) so you can’t have a template return anything else other than a string. Although, in this card, I implemented two special cases which are exceptions to this rule:
Any template which returns the string “true” or “false” will be treated as a boolean, this allows you to template boolean options of cards
If you template the entities or state_filter option of a card (e.g. entities_template or state_filter_template) the return value will be parsed as YAML/JSON
I was trying to cast states.this.entity_id | string but I think I see it now… I was using states[...] instead of states(...) to get the entity - old coding habits die hard!
Either way, your solution worked great - thanks again
I got the state text updated and I added the secondary row info for the IP address. Now I am trying to change the color of the icon using Lovelace-Card-Mod, but it looks like the condition isn’t being parsed - it’s not passing it through to the client. I’ve tried several different ways of doing this:
It should be just is_state("this.entity_id", "home") and not is_state(states("this.entity_id"), 'home')
Putting the style at that level is setting it for the whole card, so it won’t have access to the entity id
If you are still using auto-entities there, you would need the style to be nested under the options section so it will apply to every entity something like this:
options:
state_template: |
{{ "Online" if is_state("this.entity_id","home") else "Offline" }}
style: |
:host {
--paper-item-icon-color:
{%- if is_state("this.entity_id","home") -%}
green
{%- endif -%};
}
Awesome. I was getting there slowly, but I’m completely new to Jinja templates. I had figured out that the style was at the wrong level but I was trying to template the whole style option instead of just the color value.