trvrnrth / esphome-bsec-bme680

ESPHome component for the Bosch BME680 sensor via BSEC providing temperature, humidity, pressure and indoor air quality measurements.
85 stars 17 forks source link

Enhancement: iaq accuracy as numeric sensor value #13

Closed martin-at-schorsch closed 3 years ago

martin-at-schorsch commented 3 years ago

Nice work, thx!

When storing values in a database like influxdb, iaq accuracy as numeric sensor value in addition to text would be nice.

wifwucite commented 3 years ago

You should be able to add that via configuration: take a look at the template sensor. You can specify a lambda that takes the current state of the iaq accuracy text sensor and converts it to a numeric value.

trvrnrth commented 3 years ago

As @wifwucite suggests a lambda would work nicely, but since the changes to support an optional numeric sensor are pretty small I'll add that option too as it's a little bit neater :)

itsyoshio commented 3 years ago

Yup, i'd like a numeric sensor aswell.

Would a 0-100% scale make sense in terms of Air Quality Index or would it "just" be an int ranging from 0 to 500? Maybe there's another scale that would be more meaningful, but my guess is that an Air Quality of >= 50% should alarm any Person.

Update: For now i did this with mini-graph-card

image

type: 'custom:mini-graph-card'
name: Air Quality
icon: 'mdi:air-filter'
hours_to_show: 2
points_per_hour: 6
lower_bound: 0
upper_bound: ~100
lower_bound_secondary: 0
upper_bound_secondary: 1
show:
  name: true
  icon: true
  labels: false
  labels_secondary: false
entities:
  - entity: sensor.bme680_iaq
  - entity: binary_sensor.bedroom_windows
    smoothing: false
    show_line: false
    show_points: false
    show_legend: false
    color: white
    y_axis: secondary
state_map:
  - value: 'off'
    label: closed
  - value: 'on'
    label: open
color_thresholds:
  - value: 0
    color: '#00E400'
  - value: 51
    color: '#FFFF00'
  - value: 101
    color: '#FF7E00'
  - value: 151
    color: '#FF0000'
  - value: 201
    color: '#99004C'
  - value: 301
    color: '#7E0023'

Thresholds / Colors from https://en.wikipedia.org/wiki/Air_quality_index

trvrnrth commented 3 years ago

@itsyoshio The IAQ is available as a numeric sensor already which outputs in the range 0 to 500. This issue is about exposing the accuracy as a numeric sensor in addition to the existing text sensor. Your graph setup looks like it works well.

mgschwandtner commented 3 years ago

Thx for adding the feature!