Problems with MQTT automation

Finally got it working. just in case someone is struggling of how to do it here is the code ( might be a better way)

bme680_bsec:

address: 0x77 sensor: - platform: bme680_bsec temperature: name: "BME680 Temperature" pressure: name: "BME680 Pressure" humidity: name: "BME680 Humidity" iaq: name: "BME680 IAQ" id: iaq on_raw_value: - if: condition: - sensor.in_range: id: iaq below: 50 above: 26 then:
- mqtt.publish: topic: bme680-sensor/sensor/aq/state payload: EXCELLENT - if: condition: - sensor.in_range: id: iaq below: 100 above: 51 then:
- mqtt.publish: topic: bme680-sensor/sensor/aq/state payload: GOOD
- if: condition: - sensor.in_range: id: iaq below: 150 above: 101 then:
- mqtt.publish: topic: bme680-sensor/sensor/aq/state payload: FAIR
- if: condition: - sensor.in_range: id: iaq below: 200 above: 151 then:
- mqtt.publish: topic: bme680-sensor/sensor/aq/state payload: INFERIOR - if: condition: - sensor.in_range: id: iaq above: 201 then:
- mqtt.publish: topic: bme680-sensor/sensor/aq/state payload: YOU DIE

co2_equivalent:
  name: "BME680 CO2 Equivalent"
breath_voc_equivalent:
  name: "BME680 Breath VOC Equivalent"

text_sensor: - platform: bme680_bsec iaq_accuracy: name: "BME680 IAQ Accuracy"

Thanks everybody for the help and if some one knows how to improve it I'm open to ideas!

/r/Esphome Thread