o.k.
Thanks.
Trying to filter media_players based on the source_list
attribute and a value of Roku Media Player
- but not having any luck.
include:
- domain: media_player
attributes:
source_list: '*Roku Media Player*'
Does appear itâs some kind of list/array, so not sure if that makes a difference?
It does in that it canât be done⊠well⊠not easilyâŠ
You can use the special attribute:index/key
syntax to check each entry in the list, but youâd have to check all of them manually⊠that is
include:
- attributes:
source_list:0: "*Roku Media Player*"
- attributes:
source_list:1: "*Roku Media Player*"
- attributes:
source_list:2: "*Roku Media Player*"
- attributes:
source_list:3: "*Roku Media Player*"
.. etc...
Unless youâre sure Roku Media Player is always at the same position in the list, then you only have to check that indexâŠ
Thx A) for the quick reply and B) for the awesome enhacements!
No wonder I wasnât able to figure it out, thatâs a tricky one⊠Unfortunately some devices have different channels (sources) and they change, so would need to check all - so guessing this isnât the âbest/cleanestâ option.
There is another option, Iâve noticed a supported_features
exists on all these Roku devices, but there are two different ones.
I tried get this âorâ functionality to work, but couldnât make that work either. Below was the lates iteration I tried:
include:
- domain: media_player
attributes:
- supported_features: 18876
supported_features: 19388
That would give you an AND condition, as in âmatch entities where supported_features
is 18876 (logical)AND supported_features
is 19388 simultaneouslyâ.
To match either, you need to put them in different filters:
include:
- domain: media_player
attributes:
- supported_features: 18876
- domain: media_player
attributes:
- supported_features: 19388
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!
I really wish I could help you but Iâm a novice with Lovelace.
Iâve never uses the auto-entities card and that linked post represents the peak of my involvement with the template-entity-row card. Ultimately, I didnât use it (and continued to use Custom UI) because I donât want to see templates flashed on screen whenever the page is refreshed.
ok thanks. I remember that, and it indeed still flashes the templates
Hi
Iâm trying to create a Delivery card based off the 17Track sensor and using auto-entities
to populate it, and am having some difficulties with the way the sensor stores names (it prefixes each name with 'Seventeentrack Package: '
). I was hoping I could get round this by using a name template, something like this (early days of home assistant coding, so apologies if Iâve made glaring mistakes):
- type: custom:auto-entities
show_empty: false
card:
type: glance #entities
columns: 10
title: Parcels
filter:
include:
- entity_id: "sensor.seventeentrack_package_*"
options:
name: >
{{ name|regex_replace(find='Seventeentrack Package: ', replace='', ignorecase=True) }}
but I can not get it to work. I also tried this in my configuration.yaml
, but it says it doesnât recognise the customize_glob
integration:
customize_glob:
"sensor.seventeentrack_package_*":
friendly_name: test
Does anyone know a way of changing the name of an entity grabbed by auto_entites to be a substring of itself? Thank you for any help you can give.
Try entity_id
instead of object_id
.
hi, thanks for chiming in!
I did try this before:
: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 %}
;
on the template-entity-row. it does nothing unfortunately. should I syntax it differently?
Actually, config.entity
is the entity id, not the state object.
{% set repo = config.entity %}
Yey, I figured it out. The customize_glob
problem was that I didnât realise it needed to be member of homeassistant:
, so a few indents later and that was sorted. It didnât help with the templating through. What did was using another one of @thomasloven customisations, template-entity-row
. Here what is working, with dynamic icons and nicer looking names, in case it helps someone else:
- type: custom:auto-entities
show_empty: false
card:
type: entities
column_width: 50%
columns: 2
title: Parcels
filter:
include:
- entity_id: "sensor.seventeentrack_package_*"
options:
type: "custom:template-entity-row"
name: >-
{{state_attr(config.entity, 'friendly_name')|regex_replace(find='Seventeentrack Package: ', replace='', ignorecase=True)}}
secondary: >-
{% if state_attr(config.entity, 'location') %}
{% if state_attr(config.entity, 'location') == "CN" %}
China:
{% else %}
{{state_attr(config.entity, 'location')}}:
{% endif %}
{% endif %}
{% if state_attr(config.entity, 'info_text') %}
{{state_attr(config.entity, 'info_text')}}
{% endif %}
icon: >
{% if states(config.entity) == "In Transit" %}
mdi:truck-delivery
{% elif states(config.entity) == "Delivered" %}
mdi:package-variant
{% elif states(config.entity) == "Not Found" %}
mdi:briefcase-search
{% elif states(config.entity) == "Returned" %}
mdi:directions-fork
{% elif states(config.entity) == "Undelivered" %}
mdi:help-box
{% elif states(config.entity) == "Expired" %}
mdi:timer-off
{% elif states(config.entity) == "Collection" %}
mdi:package-variant-closed
{% else %}
mdi:alert-circle
{% endif %}
# tap_action:
# action: url
# url_path: 'https://17track.net/en/track#nums={{ state_attr(config.entity, 'tracking_number') }}'
style: |
:host {
--paper-item-icon-color:
{% if states(config.entity) == "In Transit" %}
blue
{% elif states(config.entity) == "Delivered" %}
green
{% elif states(config.entity) == "Not Found" %}
red
{% elif states(config.entity) == "Returned" %}
orange
{% elif states(config.entity) == "Undelivered" %}
red
{% elif states(config.entity) == "Expired" %}
grey
{% elif states(config.entity) == "Collection" %}
purple
{% else %}
red
{% endif %}
;
animation:
{% if states(config.entity) != "In Transit" and states(config.entity) != "Delivered" %}
blink 2s ease infinite
{% endif %}
;
}
Things that still need looking into, so donât copy them, although any help would be appreciated:
- The animation bit doesnât work
- The tap_action canât be templated
- Iâve guessed the names of the âCollectionâ, âExpiredâ, âReturnedâ and âNot Deliverableâ states, for the moment
- I was desperate to use anchors, until I used them and realised they didn;t work inside Template code
- Iâve no idea what the difference between
>
and>-
at the start of a multi-line template, Iâve used them interchangeably and not noticed any difference myself.
Anyway, hope that all helps someone.
Alex
i am confused, sorryâŠ
the entity is sensor.github_home_assistant
. I want those to be colored based on the input_boolean with the same object_id, input_boolean.github_home_assistant
if config.entity is the entity_id, should I then use:
:host {
--paper-item-icon-color:
{% set id = config.entity.split('.')[1] %}
{% set repo = 'input_boolean.' + id %}
{% if states(repo) == 'on' %} gold
{% else %} green
{% endif %}
;
?
let me tryâŠ
YESS!
thank you very much Thomas!
being the magic rule, have to memorize thatâŠ
edited my dedicated post How to style using card_mod: customization in JS not working - #7 by Mariusthvdb and indicated you solved it.
I managed to get the following combination from custom:auto-entities with custom:fold-entity-row done for which the following code applies.
title: GAD
show_header_toggle: false
entities:
- input_boolean.notify_utility
- input_datetime.gad_notification_time
- type: 'custom:auto-entities'
filter:
include:
- entity_id: sensor.gad_vandaag
- entity_id: sensor.gad_morgen
- entity_id: sensor.gad_restafval
- entity_id: sensor.gad_gft
- entity_id: sensor.gad_papier
type: 'custom:fold-entity-row'
head:
type: section
label: Details
- entity_id: sensor.gad_pmd
- entity_id: sensor.gad_textiel
- entity_id: sensor.gad_kerstbomen
sort:
attribute: Sort-date
method: attribute
numeric: true
entities: null
card:
type: 'custom:fold-entity-row'
head:
type: section
label: Details
However, the reverse should be applicable, i.e. the current details should stay always and the top two entities should be allowed to roll-up. I do not seem to be able to get the âcustom: fold-entity-rowâ visible this time. Any suggestions where Iâm wrong in the revised code below?
type: custom:auto-entities
show_empty: false
card:
type: entities
title: GAD
filter:
include:
- entity_id: sensor.gad_vandaag
- entity_id: sensor.gad_morgen
- entity_id: sensor.gad_restafval
- entity_id: sensor.gad_gft
- entity_id: sensor.gad_papier
- entity_id: sensor.gad_pmd
- entity_id: sensor.gad_textiel
- entity_id: sensor.gad_kerstbomen
sort:
attribute: Sort-date
method: attribute
entities:
- entity: input_boolean.notify_utility
- entity: input_datetime.gad_notification_time
head:
label: Days
type: section
padding: 0
type: 'custom:fold-entity-row'
Indentation of rows 3-5 from the bottom, perhaps?
Thanks for thinking along with me but unfortunately no luck. I started from scratch again and deleted the code associated with the custom: auto-entities.
entities:
- entity: sensor.gad_vandaag
- entity: sensor.gad_morgen
- entity: sensor.gad_restafval
- entity: sensor.gad_gft
- entity: sensor.gad_papier
- entities:
- entity: input_boolean.notify_utility
- entity: input_datetime.gad_notification_time
head:
label: Notification Settings
type: section
padding: 0
type: 'custom:fold-entity-row'
show_header_toggle: false
style: |
ha-card {
border: solid 2px var(--primary-color);
}
title: GAD
type: entities
Now i need to find out how to insert the necessary lines to apply the custom:auto-entities to the top five entities such that they will be sorted based on
sort:
attribute: Sort-date
method: attribute
numeric: true
Any lead would be appreciated.
You could try something like:
type: custom:auto-entities
filter:
include:
- entity: sensor.gad_*
sort:
method: attribute
...
- type: custom:fold-entity-row
head:
...
entities:
- input_boolean...
- input_datetime...
I.e. sort the waste types separately.
A filter that has a type:
property will not be processed as a filter, but just passed through as it is.
Bingo!
type: 'custom:auto-entities'
show_empty: false
card:
type: entities
title: GAD
filter:
include:
- entity_id: sensor.gad_*
sort:
attribute: Sort-date
method: attribute
numeric: true
- type: 'custom:fold-entity-row'
head:
label: Notification Settings
type: section
padding: 0
entities:
- entity: input_boolean.notify_utility
- entity: input_datetime.gad_notification_time
show_header_toggle: false
style: |
ha-card {
border: solid 2px var(--primary-color);
}
title: GAD
Thanks a lot!
Thomas, this is working fine now. only issue left might be that the template isnât auto-updating, and needs a manual refresh. Can I set an entity for the template so it updates on that entity_id?
:host {
--paper-item-icon-color:
{% set id = config.entity.split('.')[1] %}
{% set repo = 'input_boolean.' + id %}
{% if states(repo) == 'on' %} gold
{% else %} green
{% endif %}
;