Only by using a ātemplateā option as a filter.
Hi, With this card im trying to add and remove devices from my vpn gateway,
Only does the option not work for the template it seams.
Does someone has a solution?
type: custom:auto-entities
card:
type: entities
filter:
template: >
{% for device in states.device_tracker %}
{% if state_attr(device.entity_id,'ip') | regex_match('192.168.5.(1[5-9]\d|2[0-4]\d)') -%}
{% if states('binary_sensor.vpn' + state_attr(device.entity_id,'ip') | replace('.','_')) != "on" -%}
{{ device.entity_id}},
{%- endif %}
{%- endif %}
{% endfor %}
options:
tap_action:
action: call-service
service: script.vpn_add
data:
entity_id: this.entity_id
Thanks for this awesome card, Iām using it to show āabnormalā states for my sensors (water, gas, smoke, etc) so that they only will show up if triggered. That works great.
Iām now trying to show my triggered camera images from Blue Iris, but only if it contains a valid camera image, e.g. the camera has triggered an alert in Blue Iris.
I have set up one MQTT camera entity in HA for each of my cameras, and those get the trigger screenshot from Blue Iris through MTTQ. This works just fine, each time a camera triggers an alert the corresponding MQTT camera gets the alert screenshot from Blue Iris.
But I would like to only show the camera image if it contains an actual image, if the corresponding Blue Iris camera has not been triggered the MQTT camera entity will not contain any picture/screenshot of the alert. But I can figure out how to use this card and make a filter that checks if the MQTT camera contains a valid image or not. Iām trying to use a picture-glance card for this, is this even possible?
Example code:
type: custom:auto-entities
card:
type: picture-glance
camera_view: auto
entities: []
camera_image: camera.front_door_mqtt
filter:
include:
- entity_id: camera.front_door_mqtt
show_empty: false
This will of course show the camera image based on the āincludeā filter, or just a blank image if the camera contains no valid image. What I cannot figure out is how to make an āexcludeā filter that excludes the camera entity if it does not contain a valid image.
Any ideas on how to achieve that anyone?
Paste your code into Dev Tools ā Template and then post here an output.
May be I am wrong - please correct me.
You have a card:
type: some_type
some_option: camera.some_entity_id
And then you want to show this card only for ONE particular entity dependingly on some conditions, like:
if CONDITION == true for entity_1 -> show a card for entity_1
if CONDITION == true for entity_2 -> show a card for entity_2
...
What you can do is:
type: custom:auto-entities
card:
type: vertical-stack
card_param: cards
filter:
- include:
...some_filter
options:
type: some_type
some_option: this.entity_id
...other options for card
or rewrite the same code for using a ātemplateā filter (if filtering may be done by templates only).
Responding to myself here, because after digging some more I found a rather simple solution to this.
I added the āavailability_topicā attribute to my MQTT cameras and made sure that Blu Iris sends the payload āonlineā as well as the image whenever it detects motion. My MQTT cameras will then have the state āunavailableā if no motion has been detected, this will change to āidleā as soon as it gets an image and āonlineā as its āavailability_topicā. The latter was the key to the solution. Now the āpicture-glanceā cards for each of my MQTT cameras will only show if any movement has been detected, in which case it shows the snapshot from the last alert. Not sure if this is the easiest way to achieve this, but it works.
Working code:
type: custom:auto-entities
card:
type: picture-glance
camera_view: auto
entities: []
camera_image: camera.front_door_mqtt
filter:
include:
- entity_id: camera.front_door_mqtt
state: idle
show_empty: false
Thanks, yes thatās how it works.
My issue was that I didnāt have something suitable to use as a filter, which I have now solved as per my post below (or above). Thanks again!
This is not a case for auto-entities
.
If you have only ONE camera entity and you need to show the card for this only entity_id conditionally - use a standard conditional card.
I donāt know if there was an update, but suddenly this doesnāt work anymore:
type: vertical-stack
cards:
- type: custom:mushroom-title-card
subtitle: Lights switched on ({{states('sensor.aantal_ingeschakelde_lichten')}})
- type: custom:auto-entities
show_empty: false
card:
type: entities
sort:
method: name
numeric: false
filter:
include:
- domain: light
options:
type: custom:mushroom-template-card
primary: '{{ states[''this.entity_id''].name.replace(''lights'', ''Lights'') }}'
secondary: '{{ states[''this.entity_id''].state }}'
icon: mdi:lightbulb
icon_color: |-
{% if states['this.entity_id'].state == 'on' %}
orange
{% else %}
grey
{% endif %}
tap_action:
action: toggle
double_tap_action:
action: none
exclude:
- state: 'off'
- state: unavailable
- attributes:
friendly_name: Group -*
- attributes:
friendly_name: Sun blinds
- attributes:
friendly_name: LED*
- attributes:
type: browser_mod
When I remove the āoptionsā part, it worksā¦but I want the mushroom part.
Any idea ?
I have the exact same problem. It works without the options section included. It also only seems to not work for lights. I have another card that shows active motion sensors and it still works just fine.
So nice! I was looking for something like this for so long !! But what I didnāt liked about it was the hardcoded speaker_group entities.
āspeaker_groupā: {āplatformā: āsonosā,āshow_group_countā: true,āentitiesā: [
{āentity_idā: āmedia_player.ralfā,ānameā: āRalfā},
{āentity_idā: āmedia_player.badā,ānameā: āBadā},
{āentity_idā: āmedia_player.kucheā,ānameā: āKĆ¼cheā},
{āentity_idā: āmedia_player.wohnzimmerā,ānameā: āWohnzimmerā},
{āentity_idā: āmedia_player.elternā,ānameā: āElternā},
{āentity_idā: āmedia_player.annikaā,ānameā: āAnnikaā},
{āentity_idā: āmedia_player.gasteā,ānameā: āGƤsteā}]
}
The first part of the code is dynamic, so why not the speaker_group entities part?
Secondly, what I didnāt liked about it is that the āMasterā is also shown :
So what I wanted is just to show the other speakers :
So here is my version :
type: custom:auto-entities
show_empty: true
card:
type: entities
filter:
template: >-
{%- set speakers=expand(integration_entities("sonos"))|selectattr("domain","eq","media_player")|map(attribute="entity_id")|list %}
[ {% for speaker in expand(speakers) if speaker.attributes.group_members[0] == speaker.entity_id %}
{%- set speaker_group = namespace(entities=[]) %}
{%- for member in speakers if member!=speaker.entity_id %}
{%- set speaker_group.entities=speaker_group.entities+[{'entity_id' : member,'name': state_attr(member,'friendly_name')}] %}
{%- endfor %}
{{
{
'type': 'custom:mini-media-player',
'entity' : speaker.entity_id,
'artwork' : 'cover',
'group': false,
'hide': {
'power': true,
'icon': true,
'source': true
},
'speaker_group': {
'platform': 'sonos',
'sync_volume': true,
'show_group_count': true,
'entities': speaker_group.entities
}
}
}},
{%- endfor %} ]
And here in action :
Please let me know if you find a solutionā¦
Solved with the update of today
How to change the name of an included entity? Using the options:
option with name: ABC
or friendly_name: ABC
etc. did not work (while it does for secondary_level: xxx
etc.).
āoptionsā is a proper name
Just a typo. Whatās the solution?
@Ildar_Gabdullin I have 7 camera entities, and I only want to show those that have an active alert. auto-entities now does that perfectly - despite you declaring that āthis is not a case for auto-entitiesā.
For one entity (as it was in your 1st post) I would use a conventional conditional card.
But if you have 7 cameras - agree absolutely, auto-entities is a good choice! Saves a lot of code, no problems with margins between hidden conditional cards.
so experimenting with the new Tile card, and aware this might not be the best card to show inside an entities card.
My hope is to auto populate all of my Area subviews with Tile cards of lights, switches, covers and media players.
started out simple, with a auto-entities/cluttering card that can be used on any of these subviews, only using the domain and the area, so the auto-entities in that decluttering card can do the works.
Since not all of the Tile cards have (the same) features, I struggled at first setting a manual line for those in the entities card (always start verbosely), but then wanted to add that to the auto-entities (via the declutteringā¦)
can not make it happen though, as on any test I did, the dashboard returns an error. this is what I tried in the end:
default:
- features: null
card:
type: custom:auto-entities
card:
type: entities
title: '[[title]]'
card_mod:
class: class-header-margin
show_header_toggle: false
filter:
include:
- domain: '[[domain]]'
area: '[[area]]'
options:
type: custom:hui-element
card_type: tile
features:
- type: '[[features]]'
and this is what I get:
Is there a syntax issue I overlook, or cant we simply use the auto-entities card for this feature. Or, should I maybe try to add the whole line to a default value in the declutteringā¦
- type: custom:decluttering-card
template: area_domain
variables:
- title: Library lights
- area: library
- domain: light
# - features:
# - type: '[[features]]' #light-brightness
fwiw, the auto-entities can better be combined with layout card in this case:
card:
type: custom:auto-entities
card:
type: custom:layout-card
layout_type: masonry
filter:
include:
- domain: '[[domain]]'
area: '[[area]]'
options:
type: tile
showing the Tile cards individually
Is it possible to only show groups? I put all my lights into groups. I only want to list groups.
Setting the domain as āgroupsā doesnt work Any ideas?