StatusLED schalten in Abhängigkeit von Entitätswerten

Bereich rings rum zum Thema Yaml und seine Tücken.


Antworten
Tedious
Beiträge: 4
Registriert: Fr 3. Nov 2023, 08:58

StatusLED schalten in Abhängigkeit von Entitätswerten

Beitrag von Tedious »

Guten Morgen,

evtl. kann mir jemand den nötige Schubs geben :)

Es geht um eine Solax Wechselrichter-Integration. Ich habe einen WemodD1Mini an dem ein einzeln steuerbarer LED-Strip mit NeoPixelBus eingebunden ist. 8 LEDs, in einem Bilderrahmen als Statusdisplay. Hier werden Entitäten angezeigt (Unwetterwarnung, etc.), aber es sollen auch Parameter der Solaranlage angezeigt werden. Beispiele sind aktueller Hausverbrauch, Solarerzeugung, Batteriestand. Das in Abhängigkeit der Werte der Entitäten, liegt bspw. die Hauslast <500W grün, drüber Gelb bis hin zu rot. So weit, so gut. Ich verzweifle aber an dem Code Ich habe zwei Varianten gebaut, bei ersterer nimmt er immer nur die erste Bedingung, ist die nicht erfüllt geht er in den Else-Zweig

Code: Alles auswählen

alias: Energy_Solarerzeugung
description: StatusLED schalten Solarertrag
trigger:
  - platform: state
    entity_id: sensor.solax_pv_power_total
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.solax_pv_power_total
            state: "0"
        sequence:
          - service: light.turn_off
            entity_id: light.statusled_statusdisplay2
      - conditions:
          - condition: not
            conditions:
              - condition: state
                entity_id: sensor.solax_pv_power_total
                state: "0"
        sequence:
          - service: light.turn_on
            entity_id: light.statusled_statusdisplay2
            data_template:
              color_name: >
                {%- if states("sensor.solax_pv_power_total")|int<=500 -%}red {%-
                elif states("sensor.solax_pv_power_total")|int>=501 and
                states("sensor.solax_pv_power_total")|int<=2000 -%}orange (%-
                elif states("sensor.solax_pv_power_total")|int>2001 and
                states("sensor.solax_pv_power_total")|int<=5000 -%}yellow {%-
                elif states("sensor.solax_pv_power_total")|int>5001 -%}green {%-
                else -%}white{%- endif -%}
    default: []
mode: single

Denn habe ich eine Abwandlung gebaut, hier "hängt" er immer in der ersten Bedingung:

Code: Alles auswählen

alias: Energie_Solarertrag_Display
description: StatusLED 3 zeigt Solarertrag
trigger:
  - platform: state
    entity_id: sensor.solax_house_load
condition: []
action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.solax_house_load
            above: 0
            below: 501
        sequence:
          - service: light.turn_on
            entity_id: light.statusled_statusdisplay3
            data:
              brightness: 120
			  rgb_color:
                - 0
                - 139
                - 4

      - conditions:
          - condition: numeric_state
            entity_id: sensor.solax_house_load
            above: 501
            below: 1000
        sequence:
          - service: light.turn_on
            entity_id: light.statusled_statusdisplay3
            data:
              brightness: 120
              rgb_color:
                - 255
                - 145
                - 0
      - conditions:
          - condition: numeric_state
            entity_id: sensor.solax_house_load
            above: 1001
            below: 2000
        sequence:
          - service: light.turn_on
            entity_id: light.statusled_statusdisplay3
            data:
              brightness: 120
              rgb_color:
              rgb_color:
                - 255
                - 48
                - 48
      - conditions:
          - condition: numeric_state
            entity_id: sensor.solax_house_load
            below: 1
        sequence:
          - type: turn_off
            device_id: 13ac0452663a516db813be842f510f13
            entity_id: b6c54b74560b558120d9a98c666b8859
            domain: light
mode: single

Hat jemand einen Tip für mich wo mein Fehler liegt? Bin für jeden Hinweis dankbar :)

Grüße Tedious

Tedious
Beiträge: 4
Registriert: Fr 3. Nov 2023, 08:58

Re: StatusLED schalten in Abhängigkeit von Entitätswerten

Beitrag von Tedious »

Wirklich so gar niemand eine Idee? :-(

Benutzeravatar
Osorkon
Administrator
Beiträge: 1950
Registriert: Sa 17. Jul 2021, 16:53
2
Wohnort: Langenargen
Has thanked: 61 times
Been thanked: 530 times
Kontaktdaten:

Re: StatusLED schalten in Abhängigkeit von Entitätswerten

Beitrag von Osorkon »

Hallo @Tedious Dien Beitrag ist mir irgendwie durch die Lappen gegangen.

So bekommst Du das ganze zum fliegen.

Code: Alles auswählen

alias: Energy_Solarerzeugung
description: StatusLED schalten Solarertrag
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.solax_pv_power_total
    above: 0
    below: 500
    id: red
  - platform: numeric_state
    entity_id:
      - sensor.solax_pv_power_total
    above: 500
    below: 2000
    id: orange
  - platform: numeric_state
    entity_id:
      - sensor.solax_pv_power_total
    above: 2000
    below: 5000
    id: yellow
  - platform: numeric_state
    entity_id:
      - sensor.solax_pv_power_total
    above: 5000
    id: green
  - platform: numeric_state
    entity_id:
      - sensor.solax_pv_power_total
    below: 1
    id: aus
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - red
              - orange
              - yellow
              - green
        sequence:
          - service: light.turn_on
            data:
              color_name: |
                {{ trigger.id }}
            target:
              entity_id: light.statusled_statusdisplay2
      - conditions:
          - condition: trigger
            id:
              - aus
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.statusled_statusdisplay2
mode: single

Gruß
Osorkon

Einer muss ja für Ordnung sorgen. :D
Antworten