Return blank if attribute cannot be evaluated
andrew-codechimp opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
I would like to include numerous entities, some which have an attribute, some which don't but rendering secondary info on those that do not have the attribute just shows the template.
In the below example I want to include both battery_plus, which has an attribute of type & qty, but also standard batteries, which do not.
type: custom:battery-state-card
secondary_info: '{attributes.battery_type_and_quantity}'
round: 0
filter:
include:
- name: entity_id
value: '*_battery_plus'
- name: entity_id
value: '*_battery'
exclude:
- name: attributes.battery_low
value: false
bulk_rename:
- from: "Battery+"
- from: "Battery"
sort:
- state
Describe the solution you'd like
When evaluating the template within the secondary info, if it does not parse as a valid attribute then display blank.
Additional context
Also linked to #658 battery_plus will optionally hide the original battery so I'd like those not displayed to avoid duplications.
I was thinking about the same thing for a while. But I couldn't decide whether to just display nothing in such cases by default or add a "KString function" which you could use to allow missing values
A function with a default value if missing might be useful but either would work for me.
This will be a default behavior starting from 3.2.0