In case you haven’t figured it out yet, or if someone is reading this after searching for the same thing, here is an example of using multiple secondary_info fields in one entity:
As you can see here, the yaml is typed as a single entry. However, we are displaying it as two separate secondary_info fields by separating them with <br>, which is the html tag for a line break.
Has anyone managed to combine a template with a string in the then or else fields?
My code looks like this:
- entity: sensor.ha_installed_version
type: "custom:secondaryinfo-entity-row"
secondary_info: '[[ if({entity}.state == sensor.ha_available_version.state , "Up to date" , "New version available: [[ sensor.ha_available_version.state ]]") ]]'
Unfortunately, this results in a “Template matching failed” error.
I can replace "New version available: [[ sensor.ha_available_version.state ]]"
with either "New version available: " or just sensor.ha_available_version.state, both of which work. But I cannot seem to figure out how to concatenate the two.
@kikon_kike You were trying to achieve the exact same thing as me. Did you ever work it out? @iptvcld It seems you were trying something similar. Have you had any luck?
I think it would probably be simpler (easier?) to create a ‘regular’ template sensor with the if statements, and then add that sensor to secondary_info rather than trying to do it all in secondary_info.
If I click on the state I get the popup I’ve defined but if I click on the name I get the more-info card.
eg
Clicking on the ‘8.0’ gives me my popup:
Clicking on ‘Number of zones defined’ gives me more-info:
type: custom:multiple-entity-row
entity: input_number.irrigation_number_of_zones
name: Number of zones defined
tap_action:
action: call-service
service: browser_mod.popup
service_data:
title: Number of zones defined
card:
type: entities
entities:
- entity: input_number.irrigation_number_of_zones
name: ' '
deviceID:
- this
style:
font-family: Oswald
font-size: 14px
box-shadow: 0em 0em 0.5em
opacity: 0.9