this post was submitted on 20 Jul 2023
22 points (100.0% liked)

homeassistant

12129 readers
19 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 2 years ago
MODERATORS
 

I made a quick template sensor to pull in data from AirNow. After, I then found out about the post at https://lemmy.world/post/730349, but I thought it might still be useful to share for a quick glance.

template:
  - sensor:
     - name: "Air Quality"
       unique_id: "airnowaqitemplate"
       state: >
         {% set aqi = states('sensor.airnow_air_quality_index') | int %}
         {% if aqi <= 50 %}
           Good
         {% elif aqi <= 100 %}
           Moderate
         {% elif aqi <= 150 %}
           Unhealthy for Sensitive Groups
         {% elif aqi <= 200 %}
           Unhealthy
         {% elif aqi <= 300 %}
           Very Unhealthy
         {% elif aqi >= 301 %}
           Hazardous
         {% else %}
           Unknown
         {% endif %}
       icon: >
         {% set aqi = states('sensor.airnow_air_quality_index') | int %}
         {% if aqi <= 50 %}
           mdi:emoticon-happy
         {% elif aqi <= 100 %}
           mdi:emoticon-neutral
         {% elif aqi <= 150 %}
           mdi:emoticon-sad
         {% elif aqi <= 200 %}
           mdi:emoticon-sick
         {% elif aqi <= 300 %}
           mdi:emoticon-dead
         {% elif aqi >= 301 %}
           mdi:skull-crossbones
         {% else %}
           mdi:minus-circle
         {% endif %}
       availability: "{{ has_value('sensor.airnow_air_quality_index') }}"
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here