Picture Elements Card - Iconfarbe

Hi!

Ich hab hier eine Picture Elements Karte mit einigen Labels und Icons drauf.

Das funktioniert bestens, allerdings gelingt es mir nicht, die Iconfarbe anhand eines Entitätszustands einzufärben.

Sollte zB grün sein, wenn der betreffende Status den Wert “0” hat und weiß, wenn nicht.

            - type: icon
              title: Automatisch
              icon: mdi:refresh-auto
              entity: button.automower_auto
              tap_action:
                action: perform-action
                confirmation:
                  text: Automatik Modus starten?
                perform_action: button.press
                target:
                  entity_id: button.automower_auto
                data: {}
              style:
                left: 0px
                bottom: 0
                padding: 10px
                font-size: 20px
                line-height: 20px
                color: |
                  {% if is_state("sensor.automower_mower_mode", "0") %}
                    green
                  {% else %}
                    white
                  {% endif %}              
                transform: translate(0%,0%)

Wenn ich bei “color” einen Wert als string eintrage, zB “orange”, dann passt das auch, aber abhängig von einem Status mag er nicht.

Kann diese Karte das nicht oder ist mein Code grundsätzlich falsch?

Vielen Dank!

Ich rate mal das die 0 als Zahl ausgeliefert wird.

Wenn du eine Zahl vergleichen möchtest musst du states nehmen

{% if states("sensor.automower_mower_mode") | int == 0 %}
  green
{% else %}
  white
{% endif %}
1 „Gefällt mir“

Danke für den Hinweis!

Funktioniert aber leider auch nicht.

Teste das doch bei dir mal unter Werkzeuge / Template…

Mit meinem Sensor kommt das raus. (Der Sensor ist bei mir gerade 0)

{% if states("sensor.active_issues") | int == 0 %}
  green
{% else %}
  white
{% endif %}

Das Snippet ist also korrekt.

Wenn du nur dort deinen Sensor prüfst, ohne die Picture Elements Card, dann weißt du zumindest das es geht. Da ich die Picture Ellements Card nirgends verwende kann ich dann aber auch nicht mehr weiterhelfen.

Der Code funktioniert sicher, aber leider nicht für eine Iconfarbe in einem Picture-Element.

Hab die Lösung gefunden: Card_mod machts möglich :grinning_face:

            - type: icon
              title: Automatisch
              icon: mdi:refresh-auto
              entity: button.automower_auto
              tap_action:
                action: perform-action
                confirmation:
                  text: Automatik Modus starten?
                perform_action: button.press
                target:
                  entity_id: button.automower_auto
                data: {}
              style:
                left: 0px
                bottom: 0
                padding: 10px
                font-size: 20px
                line-height: 20px
                color: 
                transform: translate(0%,0%)
              card_mod:
                style: |
                  :host {
                    --card-mod-icon-color:
                        {% if states("sensor.automower_mower_mode") | int == 0 %}
                          green
                        {% else %}
                          white
                        {% endif %}
                  }