To notify myself when CO2 level rises in my home office I built custom sensors. Next, it was time to build a notification light. These will show us when to open the windows and get some fresh air in our home. I chose the ESPhome platform to connect to our home automation since it’s very easy to set up. I still had a few addressable RGB LEDs (WS2811) which fit perfectly. As a microcontroller, I used Nodemcu v2. You can find the .stl files on Github.

The blog post is divided into two steps:

  1. Hardware setup
  2. Automation

Hardware setup

First, I designed the notification light to be 3D printed. The Nodemcu is installed on the bottom. One WS2811 is installed in the middle.

Here is the ESPhome configuration I use.

esphome:
  name: led-status-1

esp8266:
  board: nodemcuv2

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "*****************"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Led-Status-1 Fallback Hotspot"
    password: "*******"

light:
  - platform: neopixelbus
    type: RGB
    variant: WS2811
    pin: GPIO3
    num_leds: 1
    name: "NeoPixel Light"
    id: led_status_1
    effects:
      - pulse:
          name: "Slow Pulse"

          update_interval: 1s
    on_turn_on:
      then:
        - light.turn_on:
            id: led_status_1

Automation configuration

After building the light it’s time to set up the automation. I have one sensor installed in each room. The automation is triggered on every change in measurement. Depending on the value the light is set to a specific color:

  • below 1000 ppm – light is turned off
  • above 1000 and below 1500 ppm – light is set to yellow
  • above 1500 and below 2500 ppm – light is set to orange
  • above 2500 – light is set to red
alias: update status light 1 with CO2 measurements
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.air_sensor_1_co2
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.air_sensor_3_co2
        above: 1000
        below: 1500
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 50
          rgb_color:
            - 245
            - 224
            - 66
        target:
          device_id: **************
  - if:
      - condition: numeric_state
        entity_id: sensor.air_sensor_1_co2
        above: 1500
        below: 2500
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 75
          rgb_color:
            - 245
            - 120
            - 66
        target:
          device_id: **************
  - if:
      - condition: numeric_state
        entity_id: sensor.air_sensor_1_co2
        above: 2500
    then:
      - service: light.turn_on
        data:
          transition: 1
          brightness_pct: 75
          rgb_color:
            - 255
            - 0
            - 0
        target:
          device_id: **************
  - if:
      - condition: numeric_state
        entity_id: sensor.air_sensor_1_co2
        below: 800
    then:
      - service: light.turn_off
        data:
          transition: 1
          brightness_pct: 100
        target:
          device_id: **************
mode: single

Conclusion

Now we have one status light on every desk which indicates when to get some fresh air. I hope this will improve the experience of working from home.