{# Define points counter #} {% set airthings_bedroom_points = 0 %} {# Fetch data from sensors #} {% set airthings_bedroom = { "co2": states('sensor.airthings_wave_airthingsbedroom_co2')|int|round, "radon": states('sensor.airthings_wave_airthingsbedroom_radon_1_day_avg')|int|round, "voc": states('sensor.airthings_wave_airthingsbedroom_voc')|int|round, "humidity": states('sensor.airthings_wave_airthingsbedroom_humidity')|int|round }%} {# Co2 thresholds#} {% if airthings_bedroom.co2 > 1000 %} {# Co2 level RED #} {% set airthings_bedroom_points = airthings_bedroom_points + 10 %} {% elif airthings_bedroom.co2 > 800 %} {# Co2 level YELLOW#} {% set airthings_bedroom_points = airthings_bedroom_points + 2 %} {% else %} {# Co2 level GREEN, don't add to points #} {% endif %} {# Radon thresholds#} {% if airthings_bedroom.radon > 150 %} {# Radon level RED #} {% set airthings_bedroom_points = airthings_bedroom_points + 10 %} {% elif airthings_bedroom.radon > 100 %} {# Radon level YELLOW#} {% set airthings_bedroom_points = airthings_bedroom_points + 2 %} {% else %} {# Radon level GREEN, don't add to points #} {% endif %} {# VOC thresholds#} {% if airthings_bedroom.voc > 2000 %} {# VOC level RED #} {% set airthings_bedroom_points = airthings_bedroom_points + 10 %} {% elif airthings_bedroom.voc > 250 %} {# VOC level YELLOW#} {% set airthings_bedroom_points = airthings_bedroom_points + 2 %} {% else %} {# VOC level GREEN, don't add to points #} {% endif %} {# Humidity thresholds#} {% if airthings_bedroom.humidity > 70 or airthings_bedroom.humidity < 25 %} {# Humidity level RED #} {% set airthings_bedroom_points = airthings_bedroom_points + 10 %} {% elif airthings_bedroom.humidity > 60 %} {# Humidity level YELLOW#} {% set airthings_bedroom_points = airthings_bedroom_points + 2 %} {% elif airthings_bedroom.humidity < 30 %} {# Humidity level YELLOW#} {% set airthings_bedroom_points = airthings_bedroom_points + 2 %} {% else %} {# Humidity level GREEN, don't add to points #} {% endif %} {# Ring color human#} {% if airthings_bedroom_points > 9 %} {# Ring RED #} {% set airthings_bedroom_ring = 'Rød' %} {% elif airthings_bedroom_points > 1 %} {# Ring YELLOW#} {% set airthings_bedroom_ring = 'Gul' %} {% else %} {# Ring GREEN, don't add to points #} {% set airthings_bedroom_ring = 'Grøn' %} {% endif %} {{ airthings_bedroom_ring }}