Créer un retour d'état depuis la dernière commande du journal de l'appareil

N’hésite pas à me contacter si tu as des demandes précises et que tu es bloqué.

L’exemple que tu avais copié et qui ne fonctionnait pas chez toi est du au fait que tu avais copié juste le custom_field de la carte qui t’intéressait et pas la position du custom_field qui est précisé en fin de code.

1 « J'aime »

J’aimerais bien avoir l’icône mdi:garage-open quand il est ouvert et mdi:garage quand il est fermé
Par ailleurs pendant la manœuvre d’environs 30 secondes j’aimerais bien avoir une variation de couleur
PS c’est d’ailleurs pour ça que je souhaitais réutiliser ton dernier code du poste de Matt1 que j’ai modifié ci-après avec mes entitées

type: custom:button-card
aspect_ratio: 9/3
custom_fields:
  cardGarage:
    card:
      type: custom:button-card
      entity: input_text.etat_porte_garage
      name: Garage
      icon: mdi:garage
      show_label: true
      label: |
        [[[
          if (states['input_text.etat_porte_garage'].state == 'Fermer')
            return '<font color= "green"><b>Fermé</font>';
          else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
            return '<font color= "red"><b>Ouvert</font>';
          else if (states['cover.garage'].state == 'Fermeture')
            return '<font color= "orange"><b>Fermeture</font>';
          else if (states['cover.garage'].state == 'Ouverture')
            return '<font color= "orange"><b>Ouverture</font>';
        ]]]
      aspect_ratio: 1/1
      styles:
        name:
          - font-size: 0.9em
          - justify-self: middle
          - align-self: end
          - color: rgba(255,255,255,0.6)
        card:
          - background-color: rgba(64,64,64,0.8)
          - box-shadow: 4px 4px 4px 0px rgba(32,32,32,0.5)
          - border: 2px rgba(211,211,211,1.0) outset
        icon:
          - border-radius: 50%
          - border: none
          - box-shadow: 0px 0px 5px 5px rgba(0,128,0,0.5)
          - box-shadow: |
              [[[
                if (states['input_text.etat_porte_garage'].state == 'Fermer')
                  return '0px 0px 5px 5px rgba(0,128,0,0.5)';
                else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
                  return '0px 0px 5px 5px rgba(255,0,0,0.5)';
                else if (states['cover.garage'].state == 'Fermeture')
                  return '0px 0px 5px 5px rgba(255,140,0,0.5)';
                else if (states['cover.garage'].state == 'Ouverture')
                  return '0px 0px 5px 5px rgba(255,140,0,0.5)';
              ]]]
          - background-color: |
              [[[
                if (states['input_text.etat_porte_garage'].state == 'Fermer')
                  return 'rgba(0,128,0,0.5)';
                else if (states['input_text.etat_porte_garagee'].state == 'Ouvert')
                  return 'rgba(255,0,0,0.5)';
                else if (states['cover.garage'].state == 'Fermeture')
                  return 'rgba(255,140,0,0.5)';
                else if (states['cover.garage'].state == 'Ouverture')
                  return 'rgba(255,140,0,0.5)';
              ]]]
          - width: 60px
          - height: 60px
          - color: |
              [[[
                if (states['input_text.etat_porte_garage'].state == 'Ouvert')
                  return 'rgba(0,255,0,1.0)';
                else if (states['input_text.etat_porte_garage'].state == 'Fermer')
                  return 'rgba(255,0,0,1.05)';
                else if (states['cover.porte_de_garage'].state == 'Fermeture')
                  return 'rgba(255,140,0,0.5)';
                else if (states['cover.porte_de_garage'].state == 'Ouverture')
                  return 'rgba(255,140,0,0.5)';
              ]]]          
        label:
          - animation: |
              [[[
                if (states['cover.garage'].state == 'Fermeture')
                  return 'blink 2s ease infinite';
                else if (states['cover.garage'].state == 'Ouverture')
                  return 'blink 2s ease infinite';
              ]]]
      tap_action:
        action: call-service
        service: script.portail_fermer
      hold_action:
        action: call-service
        service: script.portail_ouvert

Pour le changement d’icône en fonction de l’état :
forum

Le code :

type: custom:button-card
entity: input_boolean.position_garage
name: Garage
icon: |
  [[[
    if (states['input_boolean.position_garage'].state == 'off')
      return 'mdi:garage';
    else if (states['input_boolean.position_garage'].state == 'on')
      return 'mdi:garage-open';
  ]]]
show_label: true
label: |
  [[[
    if (states['input_boolean.position_garage'].state == 'off')
      return '<font color= "green"><b>fermé</font>';
    else if (states['input_boolean.position_garage'].state == 'on')
      return '<font color= "red"><b>ouvert</font>';
  ]]]
aspect_ratio: 1/1
styles:
  name:
    - font-size: 0.9em
    - justify-self: middle
    - align-self: end
    - color: rgba(255,255,255,0.6)
  card:
    - background-color: rgba(64,64,64,0.8)
    - box-shadow: 4px 4px 4px 0px rgba(32,32,32,0.5)
    - border: 2px rgba(211,211,211,1.0) outset
    - width: 150px
    - height: 150px
  icon:
    - border-radius: 50%
    - border: none
    - box-shadow: 0px 0px 5px 5px rgba(0,128,0,0.5)
    - box-shadow: |
        [[[
          if (states['input_boolean.position_garage'].state == 'off')
            return '0px 0px 5px 5px rgba(0,128,0,0.5)';
          else if (states['input_boolean.position_garage'].state == 'on')
            return '0px 0px 5px 5px rgba(255,0,0,0.5)';
        ]]]
    - background-color: |
        [[[
          if (states['input_boolean.position_garage'].state == 'off')
            return 'rgba(0,128,0,0.5)';
          else if (states['input_boolean.position_garage'].state == 'on')
            return 'rgba(255,0,0,0.5)';
        ]]]
    - width: 60px
    - height: 60px
    - color: |
        [[[
          if (states['input_boolean.position_garage'].state == 'off')
            return 'rgba(0,255,0,1.0)';
          else if (states['input_boolean.position_garage'].state == 'on')
            return 'rgba(255,0,0,1.05)';
        ]]]
tap_action:
  action: toggle
hold_action:
  action: none

Il faut modifier les input_boolean par ton entité.

Pour un clignotement (par exemple) pendant environ 30 secondes, il faudra à mon sens ajouter un timer qui démarre sur le tap_action et faire déclencher l’animation en fonction de l’état du timer (if state = active)

Ca me demandera un peu plus de temps pour te faire un exemple. Je pourrais m’y mettre en fin d’aprèm.

1 « J'aime »

Nickel, je vais rester comme ça

Merci à tous

Mince j’ai un autre problème, la carte passe derrière les autres cartes de ma page

y a t-il quelques chose à faire ?

PS : je viens seulement de le constater car avant elle était en dernière position et que maintenant je l’ai mis en premier

Edit : j’ai trouvé ! mais il a fallut que je désactive les effets sur la bordure que j’aimais bien, y a t-il une autre façon ?

Essaie de mettre la carte PFG Sud Ouest en deuxième position. Sinon, enlève le width et le height de la carte du garage et modifie l’aspect_ratio en mettant 3/1 :

type: custom:button-card
aspect_ratio: 3/1
entity: input_boolean.position_garage
name: Garage
icon: |
  [[[
    if (states['input_boolean.position_garage'].state == 'off')
      return 'mdi:garage';
    else if (states['input_boolean.position_garage'].state == 'on')
      return 'mdi:garage-open';
  ]]]
show_label: true
label: |
  [[[
    if (states['input_boolean.position_garage'].state == 'off')
      return '<font color= "green"><b>fermé</font>';
    else if (states['input_boolean.position_garage'].state == 'on')
      return '<font color= "red"><b>ouvert</font>';
  ]]]
styles:
  name:
    - font-size: 0.9em
    - justify-self: middle
    - align-self: end
    - color: rgba(255,255,255,0.6)
  card:
    - background-color: rgba(64,64,64,0.8)
    - box-shadow: 4px 4px 4px 0px rgba(32,32,32,0.5)
    - border: 2px rgba(211,211,211,1.0) outset
  icon:
    - border-radius: 50%
    - border: none
    - box-shadow: 0px 0px 5px 5px rgba(0,128,0,0.5)
    - box-shadow: |
        [[[
          if (states['input_boolean.position_garage'].state == 'off')
            return '0px 0px 5px 5px rgba(0,128,0,0.5)';
          else if (states['input_boolean.position_garage'].state == 'on')
            return '0px 0px 5px 5px rgba(255,0,0,0.5)';
        ]]]
    - background-color: |
        [[[
          if (states['input_boolean.position_garage'].state == 'off')
            return 'rgba(0,128,0,0.5)';
          else if (states['input_boolean.position_garage'].state == 'on')
            return 'rgba(255,0,0,0.5)';
        ]]]
    - width: 60px
    - height: 60px
    - color: |
        [[[
          if (states['input_boolean.position_garage'].state == 'off')
            return 'rgba(0,255,0,1.0)';
          else if (states['input_boolean.position_garage'].state == 'on')
            return 'rgba(255,0,0,1.05)';
        ]]]
tap_action:
  action: toggle
hold_action:
  action: none

image

La carte aura la même largeur que ta carte PFG

Je l’ai fait mais sans succès, l’aspect_ratio ne fonctionne pas et la carte ne génère pas l’apperçu

Mets le code de ta carte ici (en mode formaté : bouton </>)

type: custom:button-card
entity: input_text.etat_porte_garage
name: Garage
icon: |
  [[[
    if (states['input_text.etat_porte_garage'].state == 'Fermer')
      return 'mdi:garage';
    else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
      return 'mdi:garage-open';
  ]]]
show_label: true
label: |
  [[[
    if (states['input_text.etat_porte_garage'].state == 'Fermer')
      return '<font color= "green"><b>fermé</font>';
    else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
      return '<font color= "red"><b>ouvert</font>';
  ]]]
aspect_ratio: 1/1
styles:
  name:
    - font-size: 0.9em
    - justify-self: middle
    - align-self: end
  card:
    - box-shadow: 4px 4px 4px 0px rgba(32,32,32,0.5)
    - border: 2px rgba(211,211,211,1.0) outset
    - width: 150px
    - height: 150px
  icon:
    - border-radius: 50%
    - border: none
    - box-shadow: 0px 0px 5px 5px rgba(0,128,0,0.5)
    - box-shadow: |
        [[[
          if (states['input_text.etat_porte_garage'].state == 'Fermer')
            return '0px 0px 5px 5px rgba(0,128,0,0.5)';
          else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
            return '0px 0px 5px 5px rgba(255,0,0,0.5)';
        ]]]
    - background-color: |
        [[[
          if (states['input_text.etat_porte_garage'].state == 'Fermer')
            return 'rgba(0,128,0,0.5)';
          else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
            return 'rgba(255,0,0,0.5)';
        ]]]
    - width: 60px
    - height: 60px
    - color: |
        [[[
          if (states['input_text.etat_porte_garage'].state == 'Fermer')
            return 'rgba(0,255,0,1.0)';
          else if (states['input_text.etat_porte_garage'].state == 'Ouvert')
            return 'rgba(255,0,0,1.05)';
        ]]]
tap_action:
  action: call-service
  service: script.portail_fermer
hold_action:
  action: call-service
  service: script.portail_ouvert

J’ai modifié ton code ci-dessus, ça doit fonctionner donc copie l’intégralité et remplace sur ta carte.

Merci ça fonctionne

Par contre sur une carte Shutter-Row est-il possible de modifier le style d’affichage en ajoutant une bordure ?
J’ai essayé l’ajout des lignes Styles, mais sans succès même si je peux enregistrer la carte

type: custom:shutter-row
move_up_button: {}
move_stop_button: {}
move_down_button: {}
invert_position: true
invert_position_label: true
entity: cover.pfg_sud_ouest
styles:
  card:
    - box-shadow: 4px 4px 4px 0px rgba(32,32,32,0.5)
    - border: 2px rgba(211,211,211,1.0) outset