Bonjour,
je rencontre un souci de personnalisation…
J’ai mis en place une carte qui fonctionne très bien toute seule :
- auto-entities
- button-card
type: custom:auto-entities
card:
type: grid
columns: 4
square: false
card_param: cards
filter:
include:
- entity_id: sensor.concentration_*
options:
type: custom:button-card
color_type: icon
aspect_ratio: 1/1
show_name: true
show_state: true
state_display: |
[[[
if (entity.state === '0.0') return "Non présent";
else return entity.state + " " + entity.attributes.unit_of_measurement;
]]]
name: |
[[[
return entity.attributes.friendly_name.split(" ")[3].split('-')[0] + ":"
]]]
styles:
card:
- "--mdc-ripple-color": rgb(68, 115, 158)
- "--mdc-ripple-press-opacity": 0.5
- border-radius: 8px
name:
- font-size: 14px
state:
- font-weight: bold
- font-size: 12px
state:
- value: 1
operator: <
color: grey
styles:
card:
- box-shadow: 0px 0px 0px 2px grey
state:
- color: grey
- value: 2
operator: <
color: green
styles:
card:
- box-shadow: 0px 0px 0px 2px green
state:
- color: green
- value: 3
operator: <
color: rgb(242,234,26)
styles:
card:
- box-shadow: 0px 0px 0px 2px rgb(242,234,26)
state:
- color: rgb(242,234,26)
- value: 3
operator: ">="
color: red
styles:
card:
- box-shadow: 0px 0px 0px 2px red
state:
- color: red
size: 50%
exclude:
- entity_id: sensor.concentration_*
state: nul
- entity_id: sensor.concentration*j_1
sort:
method: name
reverse: false
Maintenant je souhaite l’afficher dans une popup…
- auto-entities
- button-card
- browser_mod
Et c’est là que cela se corse car le JS (voir ci-dessous) ne passe absolument pas :
state_display: |
[[[
if (entity.state === '0.0') return "Non présent";
else return entity.state + " " + entity.attributes.unit_of_measurement;
]]]
name: |
[[[
return entity.attributes.friendly_name.split(" ")[3].split('-')[0] + ":"
]]]
Il me rend totalement inactif le bouton, en investiguant avec un console.log sur la variable entity il me retourne qu’elle n’est pas définie…
Quelqu’un a-t-il connaissance d’un tour de force pour rendre fonctionnel cela ?
Merci d’avance.
Code complet avec popup :
type: custom:button-card
name: bouton
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
browser_id: THIS
data:
content:
type: custom:auto-entities
card:
type: grid
columns: 4
square: false
card_param: cards
filter:
include:
- entity_id: sensor.concentration_*
options:
type: custom:button-card
color_type: icon
aspect_ratio: 1/1
show_name: true
show_state: true
state_display: |
[[[
if (entity.state === '0.0') return "Non présent";
else return entity.state + " " + entity.attributes.unit_of_measurement;
]]]
name: |
[[[
return entity.attributes.friendly_name.split(" ")[3].split('-')[0] + ":"
]]]
styles:
card:
- "--mdc-ripple-color": rgb(68, 115, 158)
- "--mdc-ripple-press-opacity": 0.5
- border-radius: 8px
name:
- font-size: 14px
state:
- font-weight: bold
- font-size: 12px
state:
- value: 1
operator: <
color: grey
styles:
card:
- box-shadow: 0px 0px 0px 2px grey
state:
- color: grey
- value: 2
operator: <
color: green
styles:
card:
- box-shadow: 0px 0px 0px 2px green
state:
- color: green
- value: 3
operator: <
color: rgb(242,234,26)
styles:
card:
- box-shadow: 0px 0px 0px 2px rgb(242,234,26)
state:
- color: rgb(242,234,26)
- value: 3
operator: ">="
color: red
styles:
card:
- box-shadow: 0px 0px 0px 2px red
state:
- color: red
size: 50%
exclude:
- entity_id: sensor.concentration_*
state: nul
- entity_id: sensor.concentration*j_1
sort:
method: name
reverse: false
