Please give me some suggestions.
In my config there are sensors for battery_level & battery_charging for EVERY DEVICE:
binary_sensor:
- platform: template
sensors:
battery_charging_life360_mama:
friendly_name: 'battery_charging: life360_mama'
icon_template: ''
value_template: "{% .... %}"
device_class: battery_charging
sensor:
- platform: template
sensors:
battery_life360_mama:
friendly_name: 'battery: life360_mama'
unit_of_measurement: '%'
icon_template: ''
value_template: "{{ ... }}"
device_class: battery
These properties are registered as sensors to provide automatically changing icons which is provided by “device_class”:
- icon for battery_level - depending on level;
- icon for battery_charging - depending on “charging / not charging”.
There is no problems with listing all battery_level or battery_charging by auto-entities-card:
type: 'custom:auto-entities'
card:
type: entities
title: Battery state
unique: false
show_empty: true
filter:
include:
- entity_id: sensor.battery*
options:
secondary_info: last-changed
sort:
method: name
reverse: 'false'
ignore_case: false
attribute: null
first: 0
count: 100
numeric: false
type: 'custom:auto-entities'
card:
type: entities
title: Battery state
state_color: true
unique: false
show_empty: true
filter:
include:
- entity_id: '*sensor.battery_charging*'
sort:
method: name
reverse: 'false'
ignore_case: false
attribute: null
first: 0
count: 100
numeric: false
options:
secondary_info: last-changed
But now I would be happy to have both battery_level & battery_charging on ONE card with multiple-entity-card.
Without auto-entities-card it works fine - see below for ONE device:
type: entities
state_color: true
entities:
- type: 'custom:multiple-entity-row'
entity: binary_sensor.battery_charging_life360_mama
entities:
- entity: sensor.battery_life360_mama
name: level
unit: ''
- entity: sensor.battery_life360_mama
name: false
icon: true
unit: ''
name: Battery state
unit: ''
icon: ''
toggle: false
show_state: false
state_header: ''
state_color: true
But I wonder how to use auto-entities-card for this since these sensors must be automatically selected in loop.
Below there is my first try:
type: 'custom:auto-entities'
entities:
- type: section
label: 1st sample row
card:
type: entities
title: Some title
unique: false
show_empty: true
filter:
include:
- entity_id: binary_sensor.battery*
options:
type: 'custom:multiple-entity-row'
entities:
- entity: sensor.battery_life360_mama
name: level
unit: ''
- entity: sensor.battery_life360_mama
icon: true
name: false
unit: ''
unit: ''
icon: ''
toggle: false
show_state: false
state_header: ''
state_color: true
secondary_info: last-changed
sort:
method: name
reverse: 'false'
ignore_case: false
attribute: null
first: 0
count: 100
numeric: false
Look - here there is a battery_level for ONE SAME sensor.
I do not know how to show a corresponding sensor inside a loop.
Of course I can use battery_level & battery_charging as attributes of some entity like it was discussed above (🔹 Auto-entities - Automatically fill cards with entities).
But I would be happy to use these data as SENSORS because of automatically changing icons (“device_class”).
Is it possible to implement this?
Update:
Now I see one simple way:
- keep battery_level as a sensor with “device_class: battery”;
- use battery_charging as an attribute of battery_level sensor.
But in this case there is no way to change an icon of battery_charging automatically (at least without config-template-card).
Update 2:
Seems no way I can use config-template-card.
The “this.entity_id” variable cannot be used inside template “${ …}” with “states[…]” expressions.
So sad.