Je l’ai modifié pour que la jauge puisse apparaitre et que l’entité soit détectée, en ajoutant ceci au template :
variables:
entity: '[[[ return entity.entity_id ]]]'
Ce qui donne dans sa totalité, avec les petites modifs :
battery_level_card:
variables:
entity: '[[[ return entity.entity_id ]]]'
entity: '[[[ return variables.entity ]]]'
name: |
[[[
var name = entity.attributes.friendly_name ;
return name ;
]]]
label: |
[[[
var unit = entity.attributes.unit_of_measurement || '';
return (entity.state * 1).toFixed(0) + unit;
]]]
show_icon: true
show_state: false
show_label: true
template:
- no_style
- police
tap_action:
action: more-info
double_tap_action:
action: toggle
custom_fields:
barre:
card:
type: custom:bar-card
entities:
- entity: '[[[ return variables.entity ]]]'
color: var(--card-red)
direction: right
unit_of_measurement: '%'
max: 100
positions:
name: 'off'
indicator: 'off'
value: 'off'
height: 20px
width: 100%
icon: 'off'
entity_row: true
severity:
- color: var(--img-cell-red)
from: 0
to: 30
- color: var(--img-cell-yellow)
from: 30.1
to: 50
- color: var(--img-cell-blue)
from: 50.1
to: 99.9
- color: var(--img-cell-green)
from: 100
to: 100
styles:
card:
- height: 30px
- padding: 5.5px
icon:
- position: absolute
- width: 15px
- color: var(--text-on)
- left: calc((7%) - 5px)
- margin-bottom: 2px
name:
- position: absolute
- font-size: 13px
- color: var(--text-on)
- font-weight: 500
- left: calc((20%) - 15px)
label:
- position: absolute
- font-size: 13px
- color: |
[[[
var state = entity.state ;
if (state <= 30)
return "var(--red)"
if (state <= 50)
return "var(--orange)"
return "var(--text-on)"
]]]
- font-weight: 600
- right: calc((10%) + 10px)
custom_fields:
barre:
- top: '-19%'
- left: '-50%'
- width: 100%
- position: absolute
- z-index: 0
state:
- value: 30
operator: <
styles:
icon:
- color: var(--red)
state:
- color: var(--red)
- value: 50
operator: <
styles:
icon:
- color: var(--yellow)
state:
- color: var(--yellow)
- value: 99.9
operator: <
styles:
icon:
- color: var(--blue)
- value: 100
operator: '='
styles:
icon:
- color: var(--green)
- value: unknown
styles:
name:
- color: var(--red)
label:
- color: var(--red)
card:
- animation: blink 0.8s ease infinite
- value: unavailable
styles:
name:
- color: var(--red)
label:
- color: var(--red)
card:
- animation: blink 0.8s ease infinite
Pour la carte auto-entites je l’intègre avec :
options:
type: custom:button-card
template: battery_level_card
Ce qui donne par exemple pour « Tel, tablettes, ordis » et les filtres :
- type: custom:auto-entities
card:
type: entities
show_header_toggle: true
filter:
include:
- attributes:
device_class: battery
entity_id: sensor.*iphone_*
options:
type: custom:button-card
template: battery_level_card
- attributes:
device_class: battery
entity_id: sensor.*ipad_*
options:
type: custom:button-card
template: battery_level_card
- attributes:
device_class: battery
entity_id: sensor.*macbook_*
options:
type: custom:button-card
template: battery_level_card
sort:
method: state
numeric: true
ignore_case: false
ip: false
show_empty: true
Une colonne complète, avec mon header :
type: custom:layout-card
layout_type: masonry
layout:
width: 280
cards:
- type: vertical-stack
cards:
- type: entities
card_mod:
style: |
ha-card {
background-color: var(--card-background-color);
border-radius: var(--ha-card-border-radius) !important;
}
entities:
- type: custom:decluttering-card
template: header
variables:
- name: Ouvertures
- icon: mdi:home-battery
- type: custom:auto-entities
card:
type: entities
show_header_toggle: true
filter:
include:
- attributes:
device_class: battery
entity_id: sensor.porte_*
options:
type: custom:button-card
template: battery_level_card
sort:
method: state
numeric: true
ignore_case: false
ip: false
show_empty: true
- type: entities
card_mod:
style: |
ha-card {
background-color: var(--card-background-color);
border-radius: var(--ha-card-border-radius) !important;
}
entities:
- type: custom:decluttering-card
template: header
variables:
- name: Thermomètres
- icon: mdi:thermometer-lines
- type: custom:auto-entities
card:
type: entities
show_header_toggle: true
filter:
include:
- attributes:
device_class: battery
entity_id: sensor.*thermo_*
options:
type: custom:button-card
template: battery_level_card
- attributes:
device_class: battery
entity_id: sensor.*temp_*
options:
type: custom:button-card
template: battery_level_card
- attributes:
device_class: battery
entity_id: sensor.*sonde_*
options:
type: custom:button-card
template: battery_level_card
sort:
method: state
numeric: true
ignore_case: false
ip: false
show_empty: true
Bon on s’est totlament éloigné du sujet principal !