kajarit
(kajarit)
December 9, 2023, 7:18pm
1133
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?
cavester
(Mark Smith)
December 9, 2023, 8:44pm
1134
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?
jeffcrum
(Jeff Crum)
December 9, 2023, 9:00pm
1135
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 %}
1 Like
cavester
(Mark Smith)
December 9, 2023, 9:18pm
1137
Thanks. I was expecting to just enter something in the visual editor. I’ll give it a go
@cavester
I think that the previous posts were not addressed to you.
You already asked a similar question here)). My answer - here .
Another example:
- 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 %}
1 Like
cavester
(Mark Smith)
December 9, 2023, 9:54pm
1139
My bad then.
Thanks for your help.
1 Like
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.
kajarit
(kajarit)
December 10, 2023, 11:26am
1141
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 %}
1 Like
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
You are using the card in a wrong way.
The “options” tells to show a card with fixed 5 rows.
can you tell me a liitle bit more about it?
with this info i dont know how i should fix it, my yaml knowledge ist not so good
i tried this too, without success
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'
exclude:
- attributes:
severity: Minor
- attributes:
severity: Moderate
sort:
method: friendly_name
reverse: false
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
Why do you use Grid for one card?
this was the only way i found to work
Take any example for Entities card from auto-entities repo as a basis.
You do not need Grid.
Like this? this is not working
type: custom:auto-entities
card:
type: entities
title: Test
card_param: cards
filter:
include:
- domain: binary_sensor
entity_id: '*warning_landshut*'
state: 'on'
exclude:
- attributes:
severity: Minor
- attributes:
severity: Moderate
sort:
method: friendly_name
reverse: false
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
hä? i have set the card to entities, for me is it simular
stephanschleichstr13:
card_param: cards
Remove this.
Add this:
options:
- type: attribute
attribute: headline
name: Landshut
icon: mdi:alert-octagon
1 Like
this shows me not the headline, i think this was why im using the grid
type: custom:auto-entities
card:
type: entities
filter:
include:
- domain: binary_sensor
entity_id: '*warning_landshut*'
state: 'on'
exclude:
- attributes:
severity: Minor
- attributes:
severity: Moderate
sort:
method: friendly_name
reverse: false
options:
- type: attribute
attribute: headline
name: Landshut
icon: mdi:alert-octagon