When trying to write code to have the background change colors based on the humidity, it appears that the code works until the second statement, but the third statement fails to execute giving the wrong color.
Here’s an example:
entity: sensor.purpleair_indoor_humidity
color: black;
scale: 35px
title: Outdoor Humidity
type: custom:bignumber-card
noneCardClass: custom:bignumber-card
style: |
ha-card {
{% set humidity = states('sensor.purpleair_indoor_humidity') %}
{% if is_number(humidity) and humidity | int < 25 %}
background: #ff0015;
{% elif is_number(humidity) and humidity | int >= 25 | int <= 30 %}
background: #fbff00;
{% elif is_number(humidity) and humidity | int > 30 | int < 60 %}
background: #00E400;
{% elif is_number(humidity) and humidity | int >= 60 | int < 70 %}
background: #fbff00;
{% elif is_number(humidity) and humidity | int >= 70 %}
background: #ff0015;
{% endif %}
}
As you can see, the humidity should be green, but it’s displaying as yellow.
There’s no need to check if the humidity is a number with this as the float filter will replace it with 0 if it is not. In this case the background will turn fuchsia to indicate there is an issue with the sensor.
I think Tom inadvertently left out the closing curly bracket for the ha-card { } styling element.
Incidentally, if you are using the latest version of card-mod (which I assume you are using here), then it is strongly advised to use the card_mod keyword for styling Lovelace elements: