diff --git a/components/sensor/scd4x.rst b/components/sensor/scd4x.rst index 04796d3d3..a89624381 100644 --- a/components/sensor/scd4x.rst +++ b/components/sensor/scd4x.rst @@ -105,15 +105,19 @@ As of April 2022 the average fresh air Co² concentration is 419 ppm. value: 419 # outside average April 2022 id: my_scd41 -value can be a template +value can also be a template, for example to define a Home Assistant calibration service: .. code-block:: yaml - on_...: - then: - - scd4x._perform_forced_calibration_action: - value: !lambda "{ return 419 };" - id: my_scd41 + api: + services: + - service: calibrate_co2_value + variables: + co2_ppm: int + then: + - scd4x.perform_forced_calibration: + value: !lambda 'return co2_ppm;' + id: my_scd41 .. _factory_reset_action: @@ -129,39 +133,53 @@ This :ref:`action ` triggers a factory reset of the sensor. Calib then: - scd4x.factory_reset: my_scd41 -Automation ------------------ +Pressure compensation +--------------------- -Ambient pressure compensation compensation can be changed from :ref:`lambdas ` +A static ambient pressure value can be set with `ambient_pressure_compensation` or `altitude_compensation`. It can also be changed dynamically with :ref:`lambdas ` using `set_ambient_pressure_compensation()`, or by pointing `ambient_pressure_compensation_source` to a local pressure sensor. +Example with a local sensor +*************************** -``set_ambient_pressure_compensation( set_ambient_pressure_compensation(x / 1000.0);" + - platform: scd4x + measurement_mode: low_power_periodic + ambient_pressure_compensation_source: bme_pressure + temperature_offset: 0 + co2: + name: "CO2 level" + +Example with a remote sensor +**************************** + +This example creates a service `set_ambient_pressure` that can be called from Home Assistant: + +.. code-block:: yaml + + api: + services: + - service: set_ambient_pressure + variables: + pressure_mbar: int + then: + - lambda: "id(my_scd41)->set_ambient_pressure_compensation(pressure_mbar);" + + sensor: + - platform: scd4x + id: my_scd41 + measurement_mode: low_power_periodic + temperature_offset: 0 + co2: + name: "CO2 level" See Also