Just noticed that you seem to have the “s” missing from group.all_lights in the template, this may just have been a typo in your post but, if not, your template should probably be:
It seems that the issue is due to templates always returning strings. Since the open option is a boolean type rather than a string it seems that this prevents fold-entity-row from getting the correct value.
This is because it treats anything which is not equal (and of the same type) to false (!== false) as true, effectively mapping “false” to true.
There is a workaround, by templating the whole entities option as doing it that way, rather than templating individual options, avoids this issue. This works for me:
Still trying to get my bearing …
I wanted a picture card so I can have an action on the click. I wanted to resolve the picture path with a template that way I can have a different picture for each state.
Do I have a typo or am I expecting something it was not design for. I saw something earlier in the thread about covers that makes me thing this will not work, but right now I don’t see why …
I am just getting started with templating and attempting to experiment with a very simple example, but for the life of me I cannot get this to work. Basically I have an input_text entity called input_text.sunroom_camera_image, and the current value of the entity is sunroom. The following is what I currently have in my lovelace config:
I am actually trying to replace the image name with the value that is currently in the input_text entity. Since I have had so much trouble getting this to work, for test purposes I put the same value in for the title_template: of the lovelace card. I have tried a number of ways to format title_temple:, but the title always displays as a dash (-). I have copied the same string to Developer Tools/Templates, and it displays correctly as follows:
I really like this example but it picks up duplicates because for example, my phone is detected via bluetooth as well as being on my network to improve detection. This creates multiple device_trackers. I only want to see one entry. I can’t change to using ‘person’ to consolidate because I want to see visitors listed as well. How can I exclude, for example, by partial name match like entity_id contains BT ? Or anyone got a better idea?
You’re a bit restricted by what Jinja2 filters Home Assistant supports. One way of doing this is to use loops instead. You can either try to build up the JSON with string concatenation in the loop, or use a workaround like below using a Jinja2 namespace (to work around loops having a separate variable scope) and list concatenation (use to the list.append method being treated as unsafe).
type: 'custom:card-templater'
card:
type: entities
title: Who's at Home
entities_template: >-
{%- set data = namespace(entities=[]) -%}
{%- for entity in states.device_tracker | selectattr("state", "equalto",
"home") -%}
{%- if not "bt" in entity.entity_id -%}
{%- set data.entities = data.entities + [entity.entity_id] -%}
{%- endif -%}
{%- endfor -%}
{{ data.entities | list | tojson }}
entities:
- sensor.time
Ability to exclude an option ending with _template from being treated as a template - this done by adding ! to the end (e.g. content_template!: "{{state}}" for the content_template option in lovelace-home-feed-card)
Treat “true”/“false” template values as boolean to make it easier to template cards which take boolean options.
Fixed issue where the theme template variable was always using the backend selected theme rather than the currently selected one
Pass isPanel to child card for improved compatibility with cards such as iframe when view is in panel mode
Hi,Is it possible to show different cards depending on the status of a true / false sensor I want a card to be displayed if the sensor is true and a different card if the sensor is false?
I have an interesting issue. I’m using the code below and the card appears as a red line until I navigate to another view and then it loads properly. I’m using this on my tablets mounted to the wall with the custom header plug-in that has them in a kiosk mode so switching view’s is not normally possible. Any ideas on how to solve this?
What version are you using? If you are not on the latest version (0.0.9) can you try updating to that and see if it helps? That fixed an issue which was reported relating to the display of cards such as the iframe card when in panel mode (they would only take up part of the page). Although this doesn’t appear to be directly related to your issue, while reproducing the issue before creating the fix, I did get the same issue with the red line and the fix also seemed to have stopped that happening.
You can potentially do this by templating the type property using type_template, but this works best when the other options are the same between the different cards (e.g. switch between an entities or a glance card). For example:
For anything other that that, it would probably be easier to use two Conditional cards in a Vertical Stack. You could still use the card-templater inside the Conditional card if you need to template other options in the cards.
I have Updated everything.
Hass Supervisor: 217
Home Assistant 0.108.5
Card Templater 0.0.9
It seems to work on my PC the first time but on my android phone and tablets I need to switch views for it to work properly.
I’m trying to change the state value with this configuration. But just can’t get it to work. What am I doing wrong? The state just showing 22 so the template is not applied at all.