Card background adjustment

I want my background to change according to the value of a sensor so I can see in an eye blink that action is necessary. But if have something wrong in my sentence. Can someone tell me what because I don’t get errors but it seems that ‘<’ isn’t working:

This is what I made:

type: sensor
style: |
  ha-card {
    background:
    {% if is_state('sensor.luftdaten_3081_p1', '< 4.17' ) %}
       lightblue
    {% else if is_state('sensor.luftdaten_3081_p1', '< 14.17' ) %} 
       lightgreen
    {% else %}
      red
    {% endif %}
          ;
  }
entity: sensor.luftdaten_3081_p1
graph: line

Try this, note you have else if in your example where it should be elif

{% if states.sensor.luftdaten_3081_p1.state | int < 4.17 %}
       lightblue
{% elif states.sensor.luftdaten_3081_p1.state | int < 14.17 %} 
  lightgreen
{% else %}
  red
{% endif %}

That was very helpful. Thanks! As you might see, I used to be a COBOL-programmer. That’s why I used ‘else if’

I changed it to:

type: sensor
style: |
  ha-card {
    background:
    {% if is_state('sensor.luftdaten_3081_p1) | float < 4.17' ) %}
       lightblue
    {% else if is_state('sensor.luftdaten_3081_p1') float < 14.17 ) %} 
       lightgreen
    {% else %}
      red
    {% endif %}
          ;
  }
entity: sensor.luftdaten_3081_p1
graph: line

after reading about templates and the use of states. versus state('sensor… Now it works fine.
But now the next problem. I use Netatmo sensors and I want to use the wind_angle to procuce some nice pictures with a wind compass. Therefor I wanted to use the following sentences:

wind_compass:
         value_template: >-
           {% if 0.00 <= states('sensor.netatmo_wind_angle') | float <= 11.25 %}
           N
           {% elif 11.26 <= states('sensor.netatmo_wind_angle') |float <= 33.75 %}
           NNE
           {% elif 33.76 <= states('sensor.netatmo_wind_angle') | float  <= 56.25 %}
           NE
           {% elif 56.26 <= states('sensor.netatmo_wind_angle') | float  <= 78.75 %}
           ENE
           {% elif 78.76 <= states('sensor.netatmo_wind_angle') | float <= 101.25 %}
           E
           {% elif 101.26 <=states('sensor.netatmo_wind_angle') | float  <= 123.75 %}
           ESE
           {% elif 123.76 <= sstates('sensor.netatmo_wind_angle') | float <= 146.25 %}
           SE
           {% elif 146.26 <= states('sensor.netatmo_wind_angle') | float  <= 168.75 %}
           SSE
           {% elif 168.76 <= states('sensor.netatmo_wind_angle') | float <= 191.25 %}
           S
           {% elif 191.26 <= states('sensor.netatmo_wind_angle') | float  <= 213.75 %}
           SSW
           {% elif 213.76 <= states('sensor.netatmo_wind_angle') | float <= 236.25 %}
           SW
           {% elif 236.26 <= states('sensor.netatmo_wind_angle') | float  <= 258.75 %}
           WSW
           {% elif 258.76 <= states('sensor.netatmo_wind_angle') | float <= 281.25 %}
           W
           {% elif 281.26 <= states('sensor.netatmo_wind_angle') | float  <= 303.75 %}
           WNW
           {% elif 303.76 <= states('sensor.netatmo_wind_angle') | float  <= 326.25 %}
           NW
           {% elif 326.26 <= states('sensor.netatmo_wind_angle') | float <= 348.75%}
           NNW
           {% elif 348.76 <= states('sensor.netatmo_wind_angle') | float  <= 360.00 %}
           N
           {% endif %}"

I always get back ‘N’. Even if I know the wind is blowing from the South. It must have something to do with the attribute state of sensor.netatmo_wind-angle because the reading of this sensor is: SE(132°) But how do I split that up. Can someone help me with the correct code?