Mushroom Template Card - Icon & Farbe wollen nicht wie ich will

Kusei

New member
Hallo,
ich möchte im Dashboard zu meinem Balkonkraftwerk anzeigen lassen, welche Wattzahl mein Balkonkraftwerk aktuell produziert.
Die Wattzahl über die sekundären Informationen funktionieren auch!

Außerdem soll sich das Icon anders einfärben, wenn nichts oder sehr wenig produziert wird.
Aber das klappt nicht.
Wo habe ich da den Fehler im Code?

Folgenden Code nutze ich:
Code:
type: custom:mushroom-template-card
primary: akt. Leistung
secondary: '{{ states(''sensor.shellyplus1pm_80646fe5fdcc_switch_0_power'') }} Watt'
icon: |-
  {% if is_state('shellyplus1pm_80646fe5fdcc_switch_0_power', '> 0%') %}
    mdi:solar-power-variant-outline
  {% else %}
    mdi:solar-power-variant
  {% endif %}
entity: sensor.shellyplus1pm_80646fe5fdcc_switch_0_power
icon_color: |-
  {% if is_state('shellyplus1pm_80646fe5fdcc_switch_0_power', '> 0%') %}
    blue
  {% else %}
   yellow
  {% endif %}
multiline_secondary: false
fill_container: false
 
Mit is_state('shellyplus1pm_80646fe5fdcc_switch_0_power', '> 0%') prüft Du, ob der Wert der Entität > 0% entspricht, also ganz genau das als Zustand ausgegeben wird. Wenn Du das oben als Ausgabe mit Watt dahinter nutzt bezweifle ich stark, dass es diese Ausgabe haben kann, das wäre dann ja "> 0% Watt" als Anzeige.

Möchtest Du prüfen, ob der Wert größer Null ist und falls ja Icon und Iconfarbe anpassen?
 
Hallo,
ich habe es nun hinbekommen:
Das Icon wechselt die Farbe, wenn das Balkonkraftwerk produziert.
Die Sekundäranzeige zeigt den Wert in Watt an.

Code:
type: custom:mushroom-template-card
primary: akt. Leistung
secondary: '{{ states(''sensor.shellyplus1pm_80646fe5fdcc_switch_0_power'') }} Watt'
icon: |-
  {% set state = states('sensor.shellyplus1pm_80646fe5fdcc_switch_0_power') %}
  {% if is_number(state) and state | float > 1%}
   mdi:solar-power-variant
  {% else%}
   mdi:solar-power-variant
  {% endif %}
entity: sensor.shellyplus1pm_80646fe5fdcc_switch_0_power
icon_color: |-
  {% set state = states('sensor.shellyplus1pm_80646fe5fdcc_switch_0_power') %}
  {% if is_number(state) and state | float > 1%}
    yellow
  {% else%}
   grey
  {% endif %}
multiline_secondary: false
fill_container: false
 

Zurzeit aktive Besucher

Letzte Anleitungen

Statistik des Forums

Themen
4.574
Beiträge
46.828
Mitglieder
4.208
Neuestes Mitglied
ramfresser
Zurück
Oben