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

support [id] value for ifclause #22

Closed itsyoshio closed 3 years ago

itsyoshio commented 3 years ago

I'd be nice if the Library could support [id] to be able to do things like conditionals on the text_sensor's state.

text_sensor:
  - platform: bme680_bsec
    id: iaq_accuracy
    iaq_accuracy:
      # IAQ accuracy as a text value of Stabilizing, Uncertain, Calibrating, Calibrated
      name: "BME680 IAQ Accuracy"
    on_value:
      then:
        - if:
          condition:
            or: 
              - text_sensor.state:
                id: iaq_accuracy
                state: 'Uncertain'

Since id: iaq_accuracy is not a valid Line, text_sensor.state->id does not work

ESPHome Docs for this feature are found here

trvrnrth commented 3 years ago

You're putting the id in the wrong place. The following ought to work:

text_sensor:
  - platform: bme680_bsec
    iaq_accuracy:
      # IAQ accuracy as a text value of Stabilizing, Uncertain, Calibrating, Calibrated
      id: iaq_accuracy
      name: "BME680 IAQ Accuracy"
    on_value:
      then:
        - if:
          condition:
            or: 
              - text_sensor.state:
                id: iaq_accuracy
                state: 'Uncertain'
itsyoshio commented 3 years ago

Thanks, works like a charm! Sorry about this.