having an issue with icon_coloring in my auto-entities card using the entities in a group, based on input_boolean s state with the same object_idās. the template is based on the icon template in the docs for card-mod: https://github.com/thomasloven/lovelace-card-mod#styling-entity-and-glance-cards
- type: custom:auto-entities
card:
type: entities
style: |
:host {
--paper-item-icon-color:
{% set id = config.entity.entity_id.split('.')[1] %}
{% set repo = 'input_boolean.' + id %}
{% if states(repo) == 'on' %} gold
{% else %} green
{% endif %}
;
}
ha-card {
box-shadow: none;
background: none;
padding: 0px;
margin: -20px;
}
filter:
include:
- group: group.github_repos_in_use
options:
tap_action:
action: more-info
hold_action:
action: navigate #url
navigation_path: weblinks
# # url_path: >
# # {{ state_attr(config.entity,'latest_release_url') }}
type: custom:template-entity-row
state: >
{% if states(config.entity) != None %}
{% if state_attr(config.entity,'latest_release_tag') %}
{{state_attr(config.entity,'latest_release_tag')}}
{% else %} {{states(config.entity)}}
{% endif %}
{% else %} Unknown
{% endif %}
secondary: >
{% if states(config.entity) != None %}
{{state_attr(config.entity,'latest_commit_message')}}
{% else %} Unknown
{% endif %}
sort:
method: name
without the icon template this card works fine listing all members of the group, albeit in the default grey-blueish color HA uses. Id like to show the sensors with a color when an input_boolean is āonā , as reflected in the template.
Am I using an incorrect place for the template? Ive also tried it in the template-entity-row , but that doesnt change the output.
I have a separate post How to style using card_mod: customization in JS not working which explains what was used before, a custom_ui js template:
sensor.github_home_assistant:
templates:
icon_color: >
var id = entity.entity_id.split('.')[1];
var repo = 'input_boolean.' + id;
if (entities[repo].state == 'on') return 'gold';
return 'green';
in developer_tools/template:
but I couldnāt get that to customize_glob, so would hope auto-entities combined with card-mod would be the answerā¦
Please help me find the correct way of doing soā¦
@123 pardon the tag but I remembered this CustomUI - discussion threadā¦ where you struggled and found a way to work it out, using template-entity-row and auto-entities using card-mod?
Ive now minimized the template to this, but still no such luck:
- type: custom:auto-entities
card:
type: entities
style: |
ha-card {
box-shadow: none;
background: none;
padding: 0px;
margin: -20px;
}
filter:
include:
- group: group.github_repos_in_use
options:
tap_action:
action: more-info
hold_action:
action: navigate
navigation_path: weblinks
type: custom:template-entity-row
style: |
:host {
--paper-item-icon-color:
{% set id = config.entity.object_id %}
{% set repo = 'input_boolean.' + id %}
{{'gold' if is_state(repo,'on') else 'green'}}
;
}
state: >
{% if states(config.entity) != None %}
{% if state_attr(config.entity,'latest_release_tag') %}
{{state_attr(config.entity,'latest_release_tag')}}
{% else %} {{states(config.entity)}}
{% endif %}
{% else %} Unknown
{% endif %}
secondary: >
{% if states(config.entity) != None %}
{{state_attr(config.entity,'latest_commit_message')}}
{% else %} Unknown
{% endif %}
sort:
method: name
the template itself should work:
would appreciate your inputā¦
thanks!