Picture-elements change the badge based on if statements?

Hello, can anyone help me with the IF Statement?

type: picture-elements
elements:
  - type: state-badge
    entity: sensor.byd_battery_box_premium_hv_temperatur
    style:
      top: 58%
      left: 70%
      transform: scale(0.7, 0.7)
      color: transparent 
      {% if states('sensor.byd_battery_box_premium_hv_temperatur') | float > 5 %}
      '--label-badge-red': green
      '--label-badge-background-color': lightgreen
      {% else %}
      '--label-badge-red': red
      '--label-badge-background-color': orange      
      {% endif %}
  - type: state-badge
    entity: sensor.shelly1pm_84cca8a81c55_temperature
    style:
      top: 25%
      left: 30%      
      transform: scale(0.7, 0.7)
      color: transparent
      '--label-badge-red': red
      '--label-badge-background-color': orange      
image: /local/plans/Stadel - Erdgeschoss.jpg

Thanks

Also that doesn’t work !?

      '--label-badge-red': {% if state('sensor.byd_battery_box_premium_hv_temperatur') | float > 5 %} green {% else %} red {% endif %}

I have not checked your using of “if” template.
But the picture elements card does NOT support templates.
You need to use card-mod.