I’ve created a template sensor to list entities in a group with a state of 'on' but in a Lovelace markdown card it shows the entity_id instead of the friendly name.
Can someone please advise what I need to change or add to get the friendly name to show in the card?
Sorry Tom, but that’s also returning ‘unavailable’.
I’ve even tried creating the group the “old way” in `groups.yaml’ and the suggested codes still show ‘unavailable’. I’ve also cleared the cache and restarted HA each time.
To try and isolate the issue, I have created a new group of different binary sensors, and used the same template sensor code for that group and it still shows ‘unavailable’ in the dashboard and Developer Tools > Templates.
I then created a new dashboard and tried adding both a template card and markdown card but still getting ‘unavailable’.
I’m assuming the issue is one of three things:
A bug in the latest HA release (unless it’s only happening to me)
An issue with my template sensor code
An issue with my code in the dashboard card
If someone could please help me solve this I would be grateful as it’s making me age quickly.
I’m sorry I have the same problem (but with light entities) but I do not understand where the (template sensor) code lives (is stored).
Where do I add (and edit for my needs):
value_template: “{{ expand(‘binary_sensor.doors’)|selectattr(‘state’, ‘eq’, ‘on’) |map(attribute=‘name’) |list }}”
in any of the files? It does not seem to be the Card itself or confugaration.yaml
Also I do not need the selected on state=‘on’, just the friendly name, what can I leave out?
It may have changed, but I believe it was config/.storage/core.config_entries
IMO, you shouldn’t edit the templates at location the code is stored. My understanding is you can render your entire config invalid if the code is incorrect.
You can place template sensors directly in the configuration file or a referenced YAML file.
Here is an example you can test in your config file to show the number of active lights.