SGP41 air quality sensor

Hi there.
Fairy new to HA and Yaml files.
I just added an SGP41 VOX/NOx sensor to an existing ESP32-C3 temp/hum setup. The htu21d works fine and so does the SGP41. No problem so far,
My problem is adding the optional temp/hum compensation.
sensor:

  • platform: htu21d
    temperature:
    name: “Living Room Temperature”
    humidity:
    name: “Living Room Humidity”

  • platform: sgp4x
    address: 0x59
    voc:
    name: “VOC Index”
    nox:
    name: “NOx Index”
    compensation:
    temperature_source: ???
    humidity_source: ???

I would like to use the htu21d temp/hum data to compensate, but I can’t get the yaml validated. Tried every trick I know. Added id’s to the temp/hum sensor and used them. Used the name as id. Don’t know how to proceed.

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

As Tom says would be clearer for us if you format your code, indentation is important. This post suggests the following.


  - platform: htu21d
    update_interval: 5s
    temperature:
      name: "Temperature HTU"
      id: air_temperature
    humidity:
      name: "Humidity"
      id: relative_humidity

I think I put the two id entries in the wrong place,
before temperature and humidity instead of after “name”, which didn’t validate.
This yaml validates and the sensor works.

i2c:
  sda: GPIO8
  scl: GPIO9
  scan: true
  frequency: 400000

sensor:
  - platform: htu21d
    temperature:
      name: "Living Room Temperature"
      id: htu21d_temp
    humidity:
      name: "Living Room Humidity"
      id: htu21d_hum

  - platform: sgp4x
    address: 0x59
    voc:
     name: "VOC Index"
    nox:
     name: "NOx Index"
    compensation:
     temperature_source: htu21d_temp
     humidity_source: htu21d_hum