sensor:
- platform: scd4x
  id: scd40
  update_interval: 5s
  temperature_offset: 4.9
  ambient_pressure_compensation_source: bme280_pressure
  co2:
    id: scd40_co2
    name: "CO2"
    <<: !include filter.yaml
  temperature:
    id: scd40_temperature
    internal: true
    #name: "CO2: Temperature"
    <<: !include filter.yaml
  humidity:
    id: scd40_humidity
    internal: true
    #name: "CO2: Humidity"
    <<: !include filter.yaml

prometheus:
  relabel:
    scd40_temperature:
      id: temperature_co2
      name: "Temperature (CO2)"
    scd40_humidity:
      id: humidity_co2
      name: "Humidity (CO2)"

button:
  - platform: template
    name: "CO2: Calibration to 419 ppm"
    on_press:
      then:
        - scd4x.perform_forced_calibration:
            value: 419  # outside average April 2022
            id: scd40
  # - platform: template
  #   name: "CO2: Factory Reset"
  #   on_press:
  #     then:
  #       - scd4x.factory_reset: scd40
