Tipp zu card-mod Icon/Zustandsfarbe in Abhängigkeit vom Zustand

ich habe hier eine Kachel-Karte (vertikaler Stapel) der mir den Zustand von 4 Türen anzeigt.

Als Kopfzeile fungiert eine Grafik mit der geöffneten Türe auf lila Hintergrung.

die darunter folgende Stapel-Karte wurde bereits mit card-mod in Farbe und Layout angepasst:

    card_mod:
      style: |
        ha-card {
        background: rgb(174,0,255);
        font-size: 18px !important;
        font-weight: 500 !important;
        line-height: 18px !important;
        --primary-text-color: black;
        --secondary-text-color: rgb(166,166,166);
        --rgb-primary-text-color: black;
        --icon-primary-color: black;
        --icon-secondary-color: rgb(242,183,19);
        }

soweit so gut, leider habe ich es bisher nicht hinbekommen, Icon und/oder Textfarbe für den Zustand in Abhängigkeit zu ändern.

also eine öffene Tür zB mit gelber Schrift & Icon darzustellen.

Wie es bei einer einzelnen Karte geht, ist ja mehrfach beschrieben, hier ist es aber eine Stapel-Karte mit 4 Entitäten von der jede einen anderen Zustand haben kann.
Danke für einen kurzen Tipp

Ich glaube ich muss mir mal Card-Mod zulegen… habs bisher nur noch nie gebraucht. Für sowas würde ich wahrscheinlich auch eher ne button-card nehmen, die ist doch von Hause aus für sowas gemacht.

Du könntest wahrscheinlich mittels hui-entity-card oder hui-tile-card einsteigen… dann müsste man aber wohl mittels nth-child() als Pseudo-Element die einzelnen Entitäten abklappern… Warum willst du das so kompliziert machen?

Vielleicht so?

type: vertical-stack
cards:
  - type: entity
    entity: binary_sensor.tur_1
  - type: entity
    entity: binary_sensor.tur_2
card_mod:
  style: |
    ha-card {
      background: rgb(174,0,255);
      font-size: 18px !important;
      --primary-text-color: black;
    }
    hui-entity-card:nth-child(1) {
      --card-mod-icon-color: {{ 'yellow' if is_state('binary_sensor.tur_1', 'on') else 'green' }};
    }
    hui-entity-card:nth-child(2) {
      --card-mod-icon-color: {{ 'yellow' if is_state('binary_sensor.tur_2', 'on') else 'green' }};
    }

Sonst zeig mal den ganzen Code der Karte und nicht nur das Styling, da muss man ja auch viel raten…

kann man machen, aber die benötigt doppelt so viel Platz auf dem dashboard

und außerdem kann man da keine Grafik als Kopfzeile verwenden

der gesamte yaml-code der Karte sieht so aus ….

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: binary_sensor.haustuer_offnung
        icon: mdi:window-open-variant
        secondary_info: last-changed
        name: Haustüre
      - entity: binary_sensor.kellertuer_tur
        secondary_info: last-changed
        name: Kellertüre
        icon: mdi:door
      - entity: binary_sensor.balkontuer_offnung
        icon: mdi:door-sliding
        secondary_info: last-changed
        name: Balkontüre
      - entity: binary_sensor.terrassentuer_offnung
        icon: mdi:door-sliding-open
        secondary_info: last-changed
        name: Terrassentüre
    state_color: true
    header:
      type: picture
      image: /api/image/serve/b820aed90783ec5a00ce99b8736b6ee2/512x512
    card_mod:
      style: |
        ha-card {
        background: rgb(174,0,255);
        font-size: 18px !important;
        font-weight: 500 !important;
        line-height: 18px !important;
        --primary-text-color: black;
        --secondary-text-color: rgb(166,166,166);
        --rgb-primary-text-color: black;
        --icon-primary-color: black;
        --icon-secondary-color: rgb(242,183,19);
        }
visibility:
  - condition: state
    entity: binary_sensor.alle_tueren
    state: "on"

weil?

das halte ich für ein Gerücht. (Sorry musste das Bild bei dir klauen) :wink:

Mit genügend Langeweile:

  • Die Icons, können sowohl für das öffnen als auch schließen selbst je Entität festgelegt werden.

  • Das Icon und der Name ist gelb, wenn Tür / Fenster geschlossen

  • Das Icon und der Name werden rot, wenn Tür / Fenster geöffnet

  • Das Icon ändert sich je nach zustand der Entität

Ich denke es sind alle Anforderungen / Vorgaben erfüllt… :slight_smile:

Das wäre der Code der Karte (ich habe meine eigenen Entitäten eingesetzt, zum Testen):

type: vertical-stack
cards:
  - type: custom:button-card
    show_entity_picture: true
    entity_picture: /local/bg_img/door.jpg
    styles:
      card:
        - padding: 0px
        - border-radius: 12px 12px 0px 0px
        - background-color: rgb(174,0,255)
        - border: none
        - box-shadow: none
        - height: 170px
      entity_picture:
        - width: 100%
  - type: custom:button-card
    entity: binary_sensor.fensterkontakt_bad_contact
    name: Bad
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-5px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:window-open-variant
        styles:
          icon:
            - color: red
          state:
            - color: red
            - font-weight: bold
          name:
            - color: red
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:window-closed-variant
        styles:
          icon:
            - color: rgb(242,183,19)
          state:
            - color: black
          name:
            - color: rgb(242,183,19)
          card:
            - background-color: rgb(174,0,255) !important
  - type: custom:button-card
    entity: binary_sensor.fensterkontakt_buro_contact
    name: Büro
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-5px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-open
        styles:
          icon:
            - color: red
          state:
            - color: red
            - font-weight: bold
          name:
            - color: red
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door
        styles:
          icon:
            - color: rgb(242,183,19)
          state:
            - color: black
          name:
            - color: rgb(242,183,19)
          card:
            - background-color: rgb(174,0,255) !important
  - type: custom:button-card
    entity: binary_sensor.fensterkontakt_hwr_contact
    name: HWR
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-5px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-sliding-open
        styles:
          icon:
            - color: red
          state:
            - color: red
            - font-weight: bold
          name:
            - color: red
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door-sliding
        styles:
          icon:
            - color: rgb(242,183,19)
          state:
            - color: black
          name:
            - color: rgb(242,183,19)
          card:
            - background-color: rgb(174,0,255)  !important
  - type: custom:button-card
    entity: binary_sensor.fensterkontakt_kueche_contact
    name: Küche
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px 0px 12px 12px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-5px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-sliding-open
        styles:
          icon:
            - color: red
          state:
            - color: red
            - font-weight: bold
          name:
            - color: red
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door-sliding
        styles:
          icon:
            - color: rgb(242,183,19)
          state:
            - color: black
          name:
            - color: rgb(242,183,19)
          card:
            - background-color: rgb(174,0,255) !important

Als alter Webdesigner stehe ich einfach auf die Button Card… da geht einfach alles mit

3 „Gefällt mir“

jetzt habe ich eine halbe Stunde ChatGPT gequält und das ist dabei herausgekommen….

card_mod:
  style: |
    ha-card {
       background: rgb(174,0,255);
       font-size: 18px !important;
       font-weight: 600 !important;
       line-height: 18px !important;
       --primary-text-color: black;
       --secondary-text-color: rgb(166,166,166);
       --rgb-primary-text-color: black;
       # --icon-primary-color: black;
       #--icon-secondary-color: white;
    }
    :host {
      --paper-item-icon-color: black;
      --primary-text-color: black;
    }
    /* Farbe, wenn "on" (offen) */
    :host([state-on]) {
      icon-color: rgb(242,183,19);
      # --primary-text-color:  rgb(242,183,19);
      # --secondary-text-color: rgb(242,183,19);
      # --text-info-color: rgb(242,183,19);
      # --rgb-text-info-color: rgb(242,183,19);
      # --rgb-secondary-text-color: rgb(242,183,19);
    }   

also gerade mal das Icon wird farblich verändert ….

und das funktioniert auch, wenn man den ganzen Kram ab

/* Farbe, wenn "on" (offen) */

einfach weg lässt, Entitätsname und Zustands-Text kann man dann wohl mit card-mod in einer Entitäts-Karde nicht verändern, schade. Naja, ein kleiner Schritt.

Eine weitere Integration (Bubble-Card) will ich nicht installieren da mein Dashboard eh schon recht zäh reagiert weil vermutlich schon zu viel installiert ist…

@Schlumperdix

da meine Lösung mir jetzt noch nicht so gefallen hat, habe ich Deine mit der Bubbel-Card mal in meiner Testumgebung nachgestellt, sieht so aus ….

also die Kopfzeilen-Grafik wird anscheinend nicht skaliert.

und es gibt so weisse Trennlinien dazwischen, die mich noch stören.

und bei einer geschlossenen Türe hätte ich gerne alles (Icon, Name, Zustands-Text) in schwarz und die sekundär-Info kann so in grau bleiben

und bei einer geöffneten Tür soll sich Icon. Name und Zustands-Text ändern und zwar in die Standard-Akzentfarbe, rgb(242,183,19)

das mit der Farbe würde ich wohl noch hinbekommen aber mit der Grafik?

das ist der aktuelle code von der ersten Türe …

type: custom:button-card
entity: binary_sensor.haustuer_offnung
name: Haustüre
show_last_changed: true
show_state: true
state_display: |
  [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
color_type: icon
styles:
  card:
    - border-radius: 0px
    - background-color: rgb(174,0,255) !important
    - padding: 10px
    - font-size: 18px
    - font-weight: 400
    - margin-top: "-5px"
    - border: none
    - box-shadow: none
    - opacity: 1
  grid:
    - grid-template-areas: "\"i n s\" \"i l s\""
    - grid-template-columns: 15% 55% 30%
    - align-items: center
  name:
    - justify-self: start
  label:
    - justify-self: start
    - color: rgb(166,166,166)
    - font-size: 14px
  state:
    - justify-self: end
    - font-size: 16px
    - color: black
    - padding-right: 10px
  icon:
    - width: 28px
state:
  - value: "on"
    icon: mdi:window-open-variant
    styles:
      icon:
        - color: red
      state:
        - color: red
        - font-weight: bold
      name:
        - color: red
      card:
        - background-color: rgb(174,0,255) !important
  - value: "off"
    icon: mdi:window-closed-variant
    styles:
      icon:
        - color: rgb(242,183,19)
      state:
        - color: black
      name:
        - color: rgb(242,183,19)
      card:
        - background-color: rgb(174,0,255) !important

die anderen 3 kann ich mir dann zurecht-basteln ….

Da kannst du mal object-fit mit angeben:

type: vertical-stack
cards:
  - type: custom:button-card
    show_entity_picture: true
    entity_picture: /local/bg_img/door.jpg
    styles:
      card:
        - padding: 0px
        - border-radius: 12px 12px 0px 0px
        - background-color: rgb(174,0,255)
        - border: none
        - box-shadow: none
        - height: 170px
      entity_picture:
        - width: 100%
        - object-fit: cover

Ich kenne aber die Original Grafik nicht. Ist die zu klein? Wo kommt der dunkle Rahmen her? Ist der in der Grafik, oder kommt der weil nicht skaliert wird?

Das sind keine weißen Trennlinien, das ist dein Hintergrund… HA baut standardmäßig zwischen Karten immer einen Abstand ein, sonst würde in deinem Dashboard ja alles aneinander kleben…
Das kannst du mit dem margin-top in dem style für die card das in jeder Karte steht beeinflussen. Derzeit steht das auf -5px. Ich tippe mal bei -8px hängen die Karten direkt aneinander.

Das findest du ganz leicht, in jeder Karte im Bereich:

...
  state:
    - value:

da gibt einen Bereich für “on” und einen für “off”

die einzelnen Teile sind dann nach icon, state, name und card sortiert.

derzeit steht off (Fenster geschlossen) bei icon, state und name rgb(242,183,19) (das ist das gelb)

wenn du das schwarz haben möchtest, kannst du statt - color: rgb(242,183,19) den Farbnamen, Hexwert oder rgb(a) reinschreiben. z.B. - color: black

Hier würde ich dann ehrlich gesagt keinen Farbwert hinterlassen. Wenn du die Standard Akzentfarbe haben möchtest, dann würde ich hier auch auf die Variable Zugreifen die HA zur Verfügung stellt… das wäre dann im “on” Teil (Fenster geöffnet) jeweils wieder da wo du es möchtest (icon, state, name) - color: var(--accent-color)

Der Code deiner Tür würde dann wohl beispielhaft so aussehen:

type: custom:button-card
entity: binary_sensor.haustuer_offnung
name: Haustüre
show_last_changed: true
show_state: true
state_display: |
  [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
color_type: icon
styles:
  card:
    - border-radius: 0px
    - background-color: rgb(174,0,255) !important
    - padding: 10px
    - font-size: 18px
    - font-weight: 400
    - margin-top: "-8px"
    - border: none
    - box-shadow: none
    - opacity: 1
  grid:
    - grid-template-areas: "\"i n s\" \"i l s\""
    - grid-template-columns: 15% 55% 30%
    - align-items: center
  name:
    - justify-self: start
  label:
    - justify-self: start
    - color: rgb(166,166,166)
    - font-size: 14px
  state:
    - justify-self: end
    - font-size: 16px
    - color: black
    - padding-right: 10px
  icon:
    - width: 28px
state:
  - value: "on"
    icon: mdi:window-open-variant
    styles:
      icon:
        - color: var(--accent-color)
      state:
        - color: var(--accent-color)
        - font-weight: bold
      name:
        - color: var(--accent-color)
      card:
        - background-color: rgb(174,0,255) !important
  - value: "off"
    icon: mdi:window-closed-variant
    styles:
      icon:
        - color: black
      state:
        - color: black
      name:
        - color: black
      card:
        - background-color: rgb(174,0,255) !important

Sieht bei mir jetzt mit allen Änderungen so aus:

Wenn dein Kopfbild nicht passt, kanns eigentlich nur an der Grafik liegen.
Wenn du nicht möchtest dass der Text des Zustand (Geöffnet/Geschlossen) gekürzt wird, kannst du auch noch mit der Breite des Grid spielen. Oder du kannst die Schriftgröße kleiner machen von dem Zustand.
Natürlich kannst du auch varieren was ausgegeben werden soll…

also Du hast mich voll überzeugt, dann werde ich in meiner Produktiv-Umgebung auch das bubble-card installieren.

die original-Grafik ist übrigens diese, und die habe ich nicht nur für Türen.

openDoor.zip.txt (37,0 KB)

[Beim Dateinamen .txt am Ende löschen und entpacken.]

andere sehen so aus …

und analog zur Farbe das Hintergrundes leuchtet eine Benachrichtigungs-LED (programmierbares Nachtlicht) in derselben Farbe…ungefähr so…

Die werden, wenn das Ereignis (Post ist da) automatisch am dashboard angezeigt und wenn man drauf-klickt wieder ausgeblendet. Andere Karten (offene Türe) verschwinden automatisch wieder, wenn der Auslöse-Zustand nicht mehr vorhanden ist

da habe ich alle wichtigen Informationen visualisiert ohne eine Alexa bemühen zu müssen, die mich ausspioniert ….

ich habe mich mit dem Thema schon des Öfteren beschäftigt, der Tipp mit dem Nachtlicht stammt von hier.

Meine eigentliche Idee zur Türe war allerdings ein pop up so wie es zB Window macht mit einer ein/ausklappbaren Seitenleiste.

also nichts, was den gesamten Bildschirm im Hintergrund ausgraut und nicht mehr bedienbar macht, solange das pop-up angezeigt wird. Bin da aber nicht mit weitergekommen.

vielleicht fällt Dir dazu noch etwas ein?

musste erst was anderes machen und taste mich hier jetzt Schritt für Schritt heran.

Die weissen Trennlinien sind schon weg aber hier komme ich nicht klar:

sieht dann so aus, also die Breite ist ok aber der obere Rand nicht ….

alles andere mit Schrift, Zustand und Icon in Abhängigkeit vom Zustand habe ich hinbekommen.

Das mit dem Rand oben ist jetzt auch kein must-have, so sieht es schon sehr gut aus, danke.

Sowas hatte ich mir echt schon gedacht … irgendeiner fragt was layoutmäßiges und Schlumperdix beantwortet auch komplizierte Fälle :slight_smile:

1 „Gefällt mir“

Ja stimmt, musste das 2013 aber aufgeben nachdem ich gebaut hatte. Da war dann keine Zeit mehr. Außerdem hat da die Hauptberufliche Kariere Fahrt aufgenommen und die hat mit dem Bereich so gar nichts zu tun :grinning_face_with_smiling_eyes:

Bin also von alter Schule…

@Cpt.Hardy: Was ist denn mit dem Abstand oben? Der soll weg über dem Bild? Zeig den Code am besten nochmal wie du es aktuell hast.

Ansonsten gucke ich heute Nachmittag….

sehr nett von Dir, also es soll so aussehen wie links und was ich habe ist das rechte.

und davon ist dies der yaml code

type: vertical-stack
cards:
  - type: custom:button-card
    show_entity_picture: true
    entity_picture: /api/image/serve/b820aed90783ec5a00ce99b8736b6ee2/512x512
    styles:
      card:
        - padding: 0px
        - border-radius: 12px 12px 0px 0px
        - background-color: rgb(174,0,255)
        - border: none
        - box-shadow: none
        - height: 170px
      entity_picture:
        - width: 100%
        - object-fit: cover
  - type: custom:button-card
    entity: binary_sensor.haustuer_offnung
    name: Haustüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:window-open-variant
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:window-closed-variant
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
  - type: custom:button-card
    entity: binary_sensor.kellertuer_tur
    name: Kellertüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-open
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
  - type: custom:button-card
    entity: binary_sensor.balkontuer_offnung
    name: Balkontüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-sliding-open
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door-sliding
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255)  !important
  - type: custom:button-card
    entity: binary_sensor.terrassentuer_offnung
    name: Terrassentüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px 0px 12px 12px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-sliding-open
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door-sliding
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important

Hi…

sorry, hab im Moment zu viel um die Ohren. Daher gestern keine Zeit zu gucken.

Aber die Sache ist ganz simpel… Ich verwende ein Beispielbild ohne diesen schwarzen Rahmen. Das Bild hat dieselbe Hintergrundfarbe wie die Karte (da fällt sowas dann nicht auf…

Das heißt Größenänderungen die in HA praktisch permanent stattfinden, je nachdem wie die Browserauflösung gerade ist (dynamisch), verändern sich die Platzverhältnisse… Das heißt die feste Höhe von 170px ist das Problem. Es handelt sich nicht im ein margin oder padding. Die Höhe von 170px ist einfach höher als das Bild in der Skalierung. Durch den schwarzen Rahmen um das Bild sieht man dass dann.

Lass einfach - height: 170px weg, dann wird es funktionieren:

Das heißt, das sollte es tun:

type: vertical-stack
cards:
  - type: custom:button-card
    show_entity_picture: true
    entity_picture: /api/image/serve/b820aed90783ec5a00ce99b8736b6ee2/512x512
    styles:
      card:
        - padding: 0px
        - border-radius: 12px 12px 0px 0px
        - background-color: rgb(174,0,255)
        - border: none
        - box-shadow: none
      entity_picture:
        - width: 100%
        - object-fit: cover
  - type: custom:button-card
    entity: binary_sensor.haustuer_offnung
    name: Haustüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:window-open-variant
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:window-closed-variant
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
  - type: custom:button-card
    entity: binary_sensor.kellertuer_tur
    name: Kellertüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-open
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
  - type: custom:button-card
    entity: binary_sensor.balkontuer_offnung
    name: Balkontüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-sliding-open
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door-sliding
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255)  !important
  - type: custom:button-card
    entity: binary_sensor.terrassentuer_offnung
    name: Terrassentüre
    show_last_changed: true
    show_state: true
    state_display: |
      [[[ return entity.state === 'on' ? 'Geöffnet' : 'Geschlossen' ]]]
    color_type: icon
    styles:
      card:
        - border-radius: 0px 0px 12px 12px
        - background-color: rgb(174,0,255) !important
        - padding: 10px
        - font-size: 18px
        - font-weight: 400
        - margin-top: "-8px"
        - border: none
        - box-shadow: none
        - opacity: 1
      grid:
        - grid-template-areas: "\"i n s\" \"i l s\""
        - grid-template-columns: 15% 55% 30%
        - align-items: center
      name:
        - justify-self: start
      label:
        - justify-self: start
        - color: rgb(166,166,166)
        - font-size: 14px
      state:
        - justify-self: end
        - font-size: 16px
        - color: black
        - padding-right: 10px
      icon:
        - width: 28px
    state:
      - value: "on"
        icon: mdi:door-sliding-open
        styles:
          icon:
            - color: var(--accent-color)
          state:
            - color: var(--accent-color)
            - font-weight: bold
          name:
            - color: var(--accent-color)
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
      - value: "off"
        icon: mdi:door-sliding
        styles:
          icon:
            - color: black
          state:
            - color: black
            - font-weight: bold
          name:
            - color: black
            - font-weight: bold
          card:
            - background-color: rgb(174,0,255) !important
1 „Gefällt mir“

sehr cool, danke. Genau das war die Lösung! Du bist Spitze :+1:

Gern geschehen. Viel Spaß damit :slight_smile:

Schaut euch mal die AlertTicker-Card an:

2 „Gefällt mir“

@Schlumperdix

das hat ja oben alles perfekt funktioniert, evtl. dürfte ich Dich hierzu nochmals um Rat fragen:

ich hätte das alles gerne in nur einer Karte, also den Fortschrittsbalken (ohne das Icon davor) unter den letzten Text der oberen Karte. Aktuell ist es ein Stapel aus 2 Karten, hier der yaml

type: vertical-stack
cards:
  - type: custom:mushroom-template-card
    secondary: >-
      Programm: {{ states('sensor.geschirrspuler_programm') }}

      Restlaufzeit: {{ states('sensor.geschirrspuler_verbleibende_zeit') }} Min.

      fertig ca. um: {{ (now() +
      timedelta(minutes=states('sensor.geschirrspuler_verbleibende_zeit')|int(0))).strftime('%H:%M')
      }} H
    icon: mdi:dishwasher
    multiline_secondary: true
    color: black
    features_position: bottom
    entity: sensor.spuelmaschine_1150w_active_power
    primary: "Spülmaschine: {{ states('sensor.geschirrspuler_zustand') }}"
    area: kuche
    card_mod:
      style: |
        ha-card {
          /* Hintergrundfarbe (Hellblau wie im Bild) */
          background: #bbdefb !important;
          border-radius: 25px;
          padding: 20px;
          position: relative;
        }

        /* Der Fortschrittsbalken als Pseudo-Element */
        ha-card::after {
          content: "";
          position: absolute;
          bottom: 40px;
          left: 5%;
          width: 90%;
          height: 12px;
          background: black; /* Schwarzer Hintergrund des Balkens */
          border-radius: 10px;
        }

        /* Der gelbe Fortschritts-Teil */
        ha-card::before {
          content: "";
          position: absolute;
          bottom: 40px;
          left: 5%;
          /* Hier den Sensor für Prozent (0-90) einfügen */
          width: {{ states('sensor.waschmaschine_fortschritt') | float * 0.9 }}%;
          height: 12px;
          background: #fdd835; /* Gelber Balken */
          border-radius: 10px;
          z-index: 1;
        }

        /* Icon oben rechts positionieren */
        mushroom-shape-icon {
          position: absolute;
          top: 15px;
          right: 15px;
          --icon-symbol-size: 20px;
          --shape-size: 35px;
        }

        /* Zeitangaben unter dem Balken (20:00 Uhr / 22:30 Uhr) */
        ha-card:after {
          content: "20:00 Uhr                                          22:30 Uhr";
          position: absolute;
          bottom: 15px;
          left: 5%;
          font-size: 12px;
          color: black;
          background: transparent;
          width: 90%;
        }
  - type: custom:entity-progress-card-template
    entity: sensor.geschirrspuler_fortschritt
    icon: mdi:dishwasher
    name: Fortschritt
    secondary: "{{ states('sensor.geschirrspuler_fortschritt') | float | round(1) }} %"
    badge_icon: mdi:update
    badge_color: green
    percent: "{{ states('sensor.geschirrspuler_fortschritt') }}"
    force_circular_background: true

die oberste Kart hat mir die KI generiert aber diese Einträge dort bzgl. Fortschrittsbalken haben bisher nicht funktioniert, daher habe ich die 2. Karte unten drunter gesetzt …

eigenlich sollte es so aussehen, wenn’s fertig ist

EDIT: vergiss den yaml code oben, ich bin schon ein Stückchen weiter … sind aber noch Fehler drin …

Geschirrspueler Karte.txt (8,4 KB)

den Original-Code habe ich hier gefunden… der hat aber damals noch Template Sensoren gebastelt, das geht heute mit der HACS Integration washData ja viel einfacher…

Hi…

Also zunächst mal wenn du washData verweden möchtest, dann funktioniert das dort nicht mit der Abfrage der Attribute. Die einzelnen Sensoren haben die Daten die du benötigst als State.

Als Beispiel:

Wenn du die aktuelle Phase abfragen möchtest (Bei dir heißt das sensor.geschirrspuler_zustand)

Dann müsstest du das in washData so abfragen:

icon: |
  [[[
    if (states['sensor.geschirrspuler_zustand'].state == 'starting') {
      return 'mdi:dots-circle';
    } else if (states['sensor.geschirrspuler_zustand'].state == 'washing') {
      return 'mdi:circle-half-full';
    } else if (states['sensor.geschirrspuler_zustand'].state == 'finishing') {
      return 'mdi:dots-circle';
    } else if (states['sensor.geschirrspuler_zustand'].state == 'end') {
      return 'mdi:dishwasher';
    }
  ]]]

Welche Stati es gibt kannst du entweder in den Entwicklerwerkzeugen sehen wenn du auf das “i” bei dem Sensor klickst (Verlauf), oder du versuchst z.B.

{{ state_attr('sensor.geschirrspuler_zustand', 'options') }}

wenn hier none kommt, dann wirst du beim Verlauf bleiben müssen oder du schaust in die Doku…

Zumindest bei mir stimmen die Stati so direkt nicht überein die du da im Code verwendest.

Auf die Weise kannst du dir erstmal alle Stati in die Karte holen für den Bereich Icon und label, sowie animation.

Deine Laufzeiten funktionieren ebenso. Auch hier gibts keine Attribute. WashdData hat da eigene Sensoren und die haben alle keine Attribute die du benötigst. In deinem kopierten Code ist das ja komplett anders gemacht worden. Da wird immer die Attribute ausgelesen…

Weiter unten im Code wird auch auf die Haupt Entität verwiesen. (z.B. if (entity.state == ‘on’) usw… Da musst du schauen, dass deine Hauptentität dafür auch brauchbar ist… derzeit hast du da ja ein W oder kW Sensor drinn… Der wird ja nicht on oder off sein… der wird ja nen Wert haben…
in “start” und “end” wird das wohl gehen, da hängen auch binärsensoren drinn. (das sind die custom_fields).

Aber in den styles für card, label und name wird sich das doch normalerweise auf die Hauptentität von ganz oben beziehen.

Leider kann ich das auch nicht mal eben ausprobieren, da müsste ich alle Sensoren in dem Code anpassen und alle Attribute abfragen rausbauen…

Du kannst dir natürlich auch das von mir umbauen… das ist schon für WashData gemacht und auch ButtonCard…

oder @Schwippser hatte ja auch jetzt erst nen coolen Style mit der Bubble Card gepostet:

ja, die sieht super toll aus, warum das Rad neu erfinden?

Deine Karte habe ich hier gefunden …

und was diese HACS dashboard Erweiterungen betrifft, kann das meinetwegen - wenn möglich - gerne mit Bordmitteln gemacht werden, ich habe glaube ich eh viel zu viele davon schon installiert und mein dashboard ist recht träge geworden.


ich muss da mal dringend ausmisten und ich vermute, das da auch vieles doppelt ist, gar nicht zum Einsatz kommt oder substituiert werden kann…