David
Mars 12, 2023, 9:46
1
Bonjour à tous
J’ai copié une carte et je l’ai modifié pour faire des essais mais je ne sais pas comment changer le nom
ce que je souhaite faire avoir Séjour off si entitée =0 et Séjour on si entitée = 1
le pense devoir travailler avec un if then mais je ne sais vraiment pas comment le faire
voici mon code
type: custom:button-card
entity: switch.prise_sapin
color: true
show_state: false
show_name: true
icon: mdi:power-plug
name: Séjour
styles:
card:
- heigh: 50px
- width: 120px
- background-color: rgba(0,0, 0, 1)
- border-radius: 8%
- border-style: solid
- border-color: rgba(250, 250, 250, 1)
- border-width: 4px
- transition: true
- border-top: 0.8rem solid rgba(115, 215, 190, 0.8)
icon:
- color: rgba(115, 215, 190, 0.8)
- height: 40px
- width: 80px
name:
- justify-self: null
- padding: 0px 10px
- font-size: 15px
- text-transform: arial
- color: rgba(250, 250, 250, 0.8)
state:
- value: 'on'
styles:
card:
- border-top: 0.8rem solid rgba(240, 11, 11, 0.8)
- background-color: rgba(0,0, 0, 1)
icon:
- color: rgba(240, 11, 11, 0.8)
Salut,
J’ai pas compris à quoi correspond entité = 1 sachant que la seule entité de ta carte switch.prise_sapin
vaut on/off mais tu peux peut-être utilise les cartes conditionnelles
:
EDIT : ok je pense avoir compris: un template sur name
Bonjour,
pour faire, il faut ajouter name:
dans - value: 'on'
et ajouter la fonction off dans state ( - value: 'off).
type: custom:button-card
entity: switch.prise_sapin
color: true
show_state: false
show_name: true
icon: mdi:power-plug
styles:
card:
- heigh: 50px
- width: 120px
- background-color: rgba(0,0, 0, 1)
- border-radius: 8%
- border-style: solid
- border-color: rgba(250, 250, 250, 1)
- border-width: 4px
- transition: true
- border-top: 0.8rem solid rgba(115, 215, 190, 0.8)
icon:
- color: rgba(115, 215, 190, 0.8)
- height: 40px
- width: 80px
name:
- justify-self: null
- padding: 0px 10px
- font-size: 15px
- text-transform: arial
- color: rgba(250, 250, 250, 0.8)
state:
- value: 'on'
name: Séjour on #ici
styles:
card:
- border-top: 0.8rem solid rgba(240, 11, 11, 0.8)
- background-color: rgba(0,0, 0, 1)
icon:
- color: rgba(240, 11, 11, 0.8)
- value: 'off'
name: Séjour off #ici
styles:
card:
- border-top: 0.8rem solid rgba(240, 11, 11, 0.8)
- background-color: rgba(0,0, 0, 1)
icon:
- color: rgba(240, 11, 11, 0.8)
David
Mars 12, 2023, 1:27
4
@Pulpy-Luke
oui l’entité c’est bien la prise sapin
@WarC0zes
Merci c’est exactement ce qu’il fallait cela fonctionne bien
Question subsidiaire :
peut-on faire la même chose avec un if then ??
Et encore merci
ta de c’est facon aussi pour le name
:
type: custom:button-card
entity: light.0x00158d0002e75493
name: |
[[[
if (states['light.0x00158d0002e75493'].state == 'on')
return "cuisine on";
return "cuisine off";
]]]
David
Mars 12, 2023, 2:31
6
@WarC0zes
Merci beaucoup cela fonctionne également.