C’est avec du Javascript qu’il faut travailler :
entity: sensor.prixcarburant_XXX
color_type: icon
custom_fields:
price: |
[[[
var carburant = '' //Variable contenant le nom du carburant disponible
var prix = '' //Variable contenant le prix du carburant disponible
if (entity.attributes.E95 && entity.attributes.E95 != 'None'){
//E95 disponible
carburant = 'E95'
prix = entity.attributes.E95 + ' €'
} else if (entity.attributes.E10 && entity.attributes.E10 != 'None') {
//E10 disponible (et E95 non disponible)
carburant = 'E10'
prix = entity.attributes.E10 + ' €'
} else {
//E95 et E10 non disponible
carburant = 'Non disponible'
prix = ''
}
return `
<span style="color: var(--text-color-sensor);">
${prix} (${carburant})
</span>`
]]]
name: Intermarché
show_icon: false
show_last_changed: false
show_name: true
styles:
card:
- border: 2px solid var(--primary-color)
- border-radius: 5px
- height: 1em
custom_fields:
price:
- background-color: 'rgba(0, 0, 0, 0)'
- position: absolute
- bottom: '-10px'
- right: 5px
- font-size: 15px
- line-height: 20px
- '--text-color-sensor': |
[[[
if ( (states['sensor.essence_sp95_best_price'].state == 'intermarche') ) return 'var(--sp95-color)';
else return 'var(--primary-color)';
]]]
grid:
- position: relative
name:
- font-variant: small-caps
- justify-self: start
- padding: 0 15px
- color: |
[[[
if ( (states['sensor.essence_sp95_best_price'].state == 'intermarche') ) return 'var(--sp95-color)';
else return 'var(--primary-color)';
]]]
type: 'custom:button-card'