>>> Join Us in the Fight Against Air Pollution

AirGradient Forum

AirGradient One - LEDs and other settings (CO2 ABC, units config)

I added the AirGradient One to my dashboard, and saw a setting to set the “LED mode” to “off”. The dashboard shows it is set to “off”, but they’re still on. Is this LED mode meant for something else?

Generally, wondering if settings like the LEDs on or off, CO2 sensor automatic calibration (on/off), configuring the units display, and such are possible to set and update without flashing, perhaps via the dashboard? I’ve flashed my other monitor before to turn off the CO2 sensor auto calibration, but always a little worried I’ll brick the system ^_^’’’

1 Like

I don’t think the functionality from the Dashboard site is ready yet to send it to devices.

As you said, you could modify the Arduino code and flash it again. It shouldn’t be possible to brick the device with a software flash, worse case you have to hold a button to get a special bootloader mode and then flash it with a modified version, so go nuts.

I notice different behavior with @MallocArray 's ESPHome flash. I can turn the LEDs off from Home Assistant, and it works, but they turn back on a few seconds later, presumably when the LED color setting code runs. I haven’t figured out yet what parameter is getting set by the LED off command, but once that’s known it should be relatively easy to conditionalize the LED logic to honor the on/off setting.

I tweaked my YAML in ESPHome to keep the LEDs dim unless the CO2 levels are high.

I haven’t tried it yet, but I wonder if you could just comment-out the brightness value in the light.turn_on and handle all of the brightness from within Home Assistant.

The brightness is currently hard coded in the s8 sensor section for running the LEDs. It also turn them on every time it gets a value from the sensor, which is why turning it off doesn’t keep it off.

I plan to make it something you can adjust separately, but haven’t gotten to that part just yet, but it is coming

Hello @MallocArray,

I am using your code and it is working well.
I added a condition to activate the LED only if they are not turned off (otherwise they keep being turned on each time the value is changed):

- platform: senseair
    # SenseAir S8 https://esphome.io/components/sensor/senseair.html
    # https://senseair.com/products/size-counts/s8-lp/
    co2:
      name: "SenseAir S8 CO2"
      id: co2
      filters:
        - skip_initial: 2
        - clamp:
            min_value: 400  # 419 as of 2023-06 https://gml.noaa.gov/ccgg/trends/global.html
      on_value:
        - if:
            condition:
                and:
                  - lambda: 'return id(co2).state < 800;'
                  - light.is_on: led_strip
            then:
              - light.turn_on:
                  id: led_strip
                  brightness: 100%
                  red: 0%
                  green: 100%
                  blue: 0%
        - if:
            condition:
                and:
                  - lambda: 'return id(co2).state >= 800 && id(co2).state < 1000;'
                  - light.is_on: led_strip
            then:
              - light.turn_on:
                  id: led_strip
                  brightness: 100%
                  red: 100%
                  green: 100%
                  blue: 0%
        - if:
            condition:
                and:
                  - lambda: 'return id(co2).state >= 1000 && id(co2).state < 1500;'
                  - light.is_on: led_strip
            then:
              - light.turn_on:
                  id: led_strip
                  brightness: 100%
                  red: 100%
                  green: 50%
                  blue: 0%
        - if:
            condition:
              and:
                - lambda: 'return id(co2).state >= 1500 && id(co2).state < 2000;'
                - light.is_on: led_strip
            then:
              - light.turn_on:
                  id: led_strip
                  brightness: 100%
                  red: 100%
                  green: 0%
                  blue: 0%
        - if:
            condition:
                and:
                  - lambda: 'return id(co2).state >= 2000 && id(co2).state < 3000;'
                  - light.is_on: led_strip
            then:
              - light.turn_on:
                  id: led_strip
                  brightness: 100%
                  red: 60%
                  green: 0%
                  blue: 60%
        - if:
            condition:
              and:
                - lambda: 'return id(co2).state >= 3000 && id(co2).state < 10000;'
                - light.is_on: led_strip
            then:
              - light.turn_on:
                  id: led_strip
                  brightness: 100%
                  red: 40%
                  green: 0%
                  blue: 0%
    id: senseair_s8
    uart_id: senseair_s8_uart

What would be nice if to change the color of one LED after the other instead of changing all of them simultaneously.

Thanks

I have another method that I just put together over the weekend that is in a testing branch. I’ll work to get it published to the main branch in an easily used file.

I did a check at the top of the list of conditions so I didn’t have to modify each one.

While an animation may look cool, I think it would take quite a bit of work to get it setup in ESPHome and isn’t a priority for me at this time. But feel free to explore it

There could also be other options where half of the bar indicates CO2 quality while the other half is PM2, or something like that, or have it reflect temp instead. All options are available if you want to work to code it.

It is not really an animation, but rather using a different color for each LED.
For example all green for values < 800.
One LED red for 800 < value < 900
Two LED red for 900 < value < 1000
and so on…

I just need to understand how to control each LED independently.

Looks like something like this could let you assign a color to specific LEDs in a strip

Light Component — ESPHome

Thanks, it was quite easy !

I’ve had a play with MallocArray’s config and managed to update the individual LEDs which then let me create additional led files to show four ranges on the LED display. The repo’s here : GitHub - cheesebo/airgradient_esphome: Extensions to MallocArray's AirGradient repo

I was going to suggest the same thing, but maybe build it in as a standard setting.