#Use auto entities to remove room name from scene cards
1 messages · Page 1 of 1 (latest)
Can you post the code for the card showing what you already have set up? You'll probably need to use some RegEx to get it to work. I posted an example the other day that removes the word "Lights" from the name. You can see that example here: #1390729382032838818 message
Yours might need to be a little bit different, though.
type: custom:auto-entities
card:
square: false
type: grid
title: Bedroom
filter:
include:
- options:
type: custom:mushroom-entity-card
tap_action:
action: toggle
area: bedroom
domain: scene
integration: 1f2cf69ae7df8a7363054039f0a6018c
exclude:
- options: {}
label: gaming_desk
- options: {}
name: Bedroom Energize
show_empty: true
card_param: cards
this is the current code which works other than the name correction not working
How are your entities named? `scene.bedroom_something'? or do they not use a naming convention?
pretty much that as they're all hue scenes in this case
Lemme see if I can try my luck with it. (Just realized I only have one scene set up...)
Making some progress. This is currently showing all scenes (which I only have one). Now, I just have to figure out have to get it to filter by area and probably the integration. (My example just removes the work Automation.)
well probably could do exclude of everything else for the integration i'd imagine?
Perhaps. I think I'm going to have to design my version to look for lights instead since I have more of them. In theory, it should just be a matter of changing the domain to scene when you go to use it.
yeah i think it is, I just got it to work actually
type: custom:auto-entities
card:
square: false
type: grid
title: Bedroom
card_param: cards
filter:
template: |-
{% for x in states.scene -%}
{%- if state_attr(x.entity_id, 'friendly_name') | regex_search("Bedroom") -%}
{{
{
'type': 'custom:mushroom-entity-card',
'entity': x.entity_id,
'name': state_attr(x.entity_id, 'friendly_name')|replace( 'Bedroom', ''),
'tap_action': 'none',
'double_tap_action': {'action':'more-info'},
'hold_action': {'action':'toggle'},
}
}},
{%- endif -%}
{%- endfor %}
exclude:
- options: {}
label: gaming_desk
- options: {}
name: Bedroom Energize
show_empty: true
that is the one that i got to work
That's actually very similar what what I came up with. Yours doesn't use the area though. It does find scene entities that with the name containing "Bedroom". This is my version: ```yaml
type: custom:auto-entities
card:
square: false
type: grid
title: Bedroom
card_param: cards
filter:
template: >-
{% for ENTITY in area_entities('bedroom')|
select('search','scene.')|
reject('is_hidden_entity') -%}
{{
{
'type': 'custom:mushroom-entity-card',
'entity': ENTITY,
'name': state_attr(ENTITY,'friendly_name') | replace('Bedroom', ''),
'tap_action': 'toggle',
'double_tap_action': {'action':'none'},
'hold_action': {'action':'none'},
}
}},
{% endfor %}
exclude:
- options: {}
label: gaming_desk
- options: {}
name: Bedroom Energize
show_empty: true
sort:
method: friendly_name
Oh it's similar because it's based on yours from that other thread that you linked i'd just adapted the logic to look for scenes and changed the name filtering
Does it still need to find entities only from the Hue integration or are these good enough?
well quite interestingly this one also grabs entities that aren't scenes but have scene in their name. Gonna guess because it's using a search?
I figured the period in scene. would handle that properly.
lemme test it again, trying some other stuff too xD
looks like the period is just being ignored somehow
type: custom:auto-entities
card:
square: false
type: grid
title: Bedroom
card_param: cards
filter:
template: >-
{% for ENTITY in area_entities('bedroom')|
select('search','scene.bedroom')|
reject('is_hidden_entity') -%}
{{
{
'type': 'custom:mushroom-entity-card',
'entity': ENTITY,
'name': state_attr(ENTITY,'friendly_name') | replace('Bedroom', ''),
'tap_action': 'toggle',
'double_tap_action': {'action':'none'},
'hold_action': {'action':'none'},
}
}},
{% endfor %}
exclude:
- options: {}
label: gaming_desk
- options: {}
name: Bedroom Energize
show_empty: true
sort:
method: friendly_name
this works though
I like this because it rejects anything hidden automatically
edit doesn't actually work.. for some reason that one makes the cards not clickable
I wonder if 'tap_action': {'action':'toggle'}, is needed, instead.
So this is kind of interesting. yaml {{ expand(area_entities("Living Room")) | selectattr('entity_id', 'search', 'light.l') | map(attribute='entity_id') | list }} which you would think returns entities that begin with light.l (so light.living_room_1, etc.). But this is what it returned: ```
[
"light.living_room_corner_led_2",
"light.living_room_corner_led_1",
"sensor.living_room_fp2_light_level",
"light.living_room2",
"light.living_room1"
]
makes me think the period is acting like a wildcard in a way in that it's searching for light(anything)l
Was told because this is using RegEx, the period might be something special:
The period (.) represents the wildcard character. Any character (except for the newline character) will be matched by a period in a regular expression; when you literally want a period in a regular expression you need to precede it with a backslash.
https://www.stat.berkeley.edu/~spector/s133/Regexp-a.html
oh that works perfectly with that
Adding an escape before period fixes it. yaml {{ expand(area_entities("Living Room")) | selectattr('entity_id', 'search', 'light\.l') | map(attribute='entity_id') | list }} now returns [ "light.living_room_corner_led_2", "light.living_room_corner_led_1", "light.living_room2", "light.living_room1" ]