Okay, so it looks like area (and device?) sorting doesn’t work, correct?
That is to say, you have to sort manually in a template, rather than sort->method.
Okay, so it looks like area (and device?) sorting doesn’t work, correct?
That is to say, you have to sort manually in a template, rather than sort->method.
correct, until the issue is fixed
Interestingly it now also works for me – I retried your code once I knew a device was offline. Maybe there’s an issue when not a single entity is unavailable. I’ll keep an eye on it – and also search for a way to wrap this into a conditional card so I can hide it when empty.
So, that is actually odd. If none matched the states of unavailable or none, it never should have gotten into the loop where you got the error.
Examples with AND, OR, NOT
AND:
type: custom:auto-entities
card:
type: entities
title: AND
filter:
include:
- domain: input_number
and:
- state: '> 10'
- state: '< 20'
And note this description in the Docs about “not necessary”:
OR:
type: custom:auto-entities
card:
type: entities
title: OR
filter:
include:
- domain: sensor
entity_id: '*xiaomi*'
or:
- attributes:
device_class: battery
- attributes:
device_class: temperature
NOT:
type: custom:auto-entities
card:
type: entities
title: NOT
filter:
include:
- domain: input_number
not:
state: '>=0'
sort:
count: 5
A simple way to show an alternative card if a filter gives an empty list:
type: custom:auto-entities
card:
type: entities
filter:
template: >-
{% set lights =
states.light|selectattr('state','==','on')|map(attribute='entity_id')|list -%}
{%- if lights|length != 0 -%}
{%- for LIGHT in lights -%}
{{
{
'entity': LIGHT,
'secondary_info': 'last-updated'
}
}},
{%- endfor -%}
{%- else -%}
{{
[
{
'type': 'custom:hui-element',
'card_type': 'markdown',
'content': 'all lights off',
'card_mod':
{
'style': 'ha-card {border: none;}'
}
}
]
}}
{%- endif %}
OR - in most cases you may just use a native “else” option:
- type: custom:auto-entities
card:
type: entities
filter:
template: >-
....
else:
type: markdown
content: all lights off
is there a way to auto list just areas? im looking and im not seeing, nor can i find what the area domain is…what am i not seeing lol
The code is quite simple, I was overcomplicating things in my post before. I ended up using Auto entities, Mushroom card and Card mod. My final code code is:
type: custom:auto-entities
filter:
include:
- domain: update
state: 'on'
options:
type: custom:mushroom-update-card
show_buttons_control: true
layout: horizontal
card_mod:
style:
mushroom-state-info$: |
.secondary {
visibility: hidden;
}
.secondary:before {
visibility: visible;
content: "{{ state_attr(config.entity, 'installed_version')}} → {{ state_attr(config.entity, 'latest_version')}}";
}
.: |
ha-card {
--secondary-text-color: white;
}
sort:
method: friendly_name
card_param: cards
card:
type: vertical-stack
It looks like this, and list vertically all current updates:
I am sorry. I read area and thought zone.
Please ignore
How do you expect this to be shown?
An area is not an entity.
You may list entities belonging to an area.
You may list area-cards for all areas.
I’d like to do the same thing, after a lot of reading, now I’m trying to achieve this by using templating, but I’m stuck at the point where I’d add sub-entities to the row.
Current code:
type: custom:auto-entities
card:
type: entities
filter:
template: |
{% for s in states.sensor -%}
{%- set value = s.entity_id -%}
{%- set pattern = '_node_status' -%}
{%- set res = value | regex_findall_index(pattern) if value is search(pattern) else "" -%}
{%- if res == pattern -%}
{{-
{
'entity': s.entity_id,
'secondary_info': 'last-changed',
'type': 'custom:multiple-entity-row',
'entities': '',
'- entity': s.entity_id,
' name': s.name,
}
-}},
{%- endif -%}
{%- endfor %}
Of course it doesn’t work after adding the entities:
part, so it seems my Jinja2 knowledge has reached it’s limit
The part after entities:
is intentionally '',
at least this way the preview window displays how it would render the template code.
Any ideas?
Hi all.
I’m trying to use this to show sensors where the state is greater than one of its attribute values
I’ve tried
state: “< this.entity_id.maximum_normal”
Where the attribute is maximum_normal
But it’s obviously wrong, the particular sensor(s) never show, regardless of state value.
Can anyone help?
The enities needs to be a list of tuple.
Not sure this is complete, but try something like this:
{% for s in states.sensor -%}
{%- set value = s.entity_id -%}
{%- set pattern = '_node_status' -%}
{%- set res = value | regex_findall_index(pattern) if value is search(pattern) else "" -%}
{%- if res == pattern -%}
{{
{
'entity': s.entity_id,
'secondary_info': 'last-changed',
'type': 'custom:multiple-entity-row',
'entities':
[{'entity': s.entity_id,
'name': s.name}],
}
}},
{%- endif -%}
{%- endfor %}
Thanks. I was expecting to just enter something in the visual editor. I’ll give it a go
- type: custom:auto-entities
card:
type: entities
filter:
template: >-
{% for SENSOR in
states.sensor|selectattr('entity_id','search','threshold.*settings') -%}
{%- if states(SENSOR.entity_id)|float(default=0) > SENSOR.attributes.some_attr|float(default=0) -%}
{{
{
'type': 'custom:template-entity-row',
'entity': SENSOR.entity_id,
'name': 'xxx',
'state': states(SENSOR.entity_id) + ' / ' + SENSOR.attributes.some_attr|string
}
}},
{%- endif -%}
{%- endfor %}
My bad then.
Thanks for your help.
yeah i was trying to find the areas to see if they ware an entity. The only reaosn i ask is that Mushroom strategy automatically creates the areas and i thought i could do the same, but i can just as easily do it manually.
Thanks, this was the missing piece!
Here’s the final version, if someone interested: (@darkson95)
type: custom:auto-entities
card:
type: entities
filter:
template: |
{% for s in states.sensor -%}
{%- set value = s.entity_id -%}
{%- set pattern = '_node_status' -%}
{%- set res = value | regex_findall_index(pattern) if value is search(pattern) else "" -%}
{%- if res == pattern -%}
{%- set name = s.name.replace('Node status', '') -%}
{%- set lvl = s.entity_id.replace(pattern, '_battery_level') -%}
{%- set low = s.entity_id.replace('sensor.', 'binary_sensor.').replace(pattern, '_low_battery') -%}
{{-
{
'type': 'custom:multiple-entity-row',
'entity': s.entity_id,
'name': name,
'secondary_info': 'last-changed',
'entities': [
{'entity': lvl,
'name': 'Battery',
'format': 'precision0'},
{'entity': low,
'name': 'Level'},
],
}
-}},
{%- endif -%}
{%- endfor %}
hey, im using this Code, someone can tell my why it shows me not only the “Severe” text? (the 4. Text only)
type: custom:auto-entities
card:
type: grid
square: false
columns: 1
card_param: cards
filter:
include:
- domain: binary_sensor
entity_id: '*warning_landshut*'
state: 'on'
options:
type: entities
style: |
ha-card {
background-color: rgba(255, 80, 80, 0.2);
font-size: 14px;
}
entities:
- type: attribute
entity: binary_sensor.warning_landshut_1
attribute: headline
name: Landshut
icon: mdi:alert-octagon
- type: attribute
entity: binary_sensor.warning_landshut_2
attribute: headline
name: Landshut
icon: mdi:alert-octagon
- type: attribute
entity: binary_sensor.warning_landshut_3
attribute: headline
name: Landshut
icon: mdi:alert-octagon
- type: attribute
entity: binary_sensor.warning_landshut_4
attribute: headline
name: Landshut
icon: mdi:alert-octagon
- type: attribute
entity: binary_sensor.warning_landshut_5
attribute: headline
name: Landshut
icon: mdi:alert-octagon
exclude:
- attributes:
severity: Minor
- attributes:
severity: Moderate
sort:
method: friendly_name
reverse: false