diff --git a/components/sensor/ezo.rst b/components/sensor/ezo.rst index 042722250..fd7e2b7a4 100644 --- a/components/sensor/ezo.rst +++ b/components/sensor/ezo.rst @@ -9,6 +9,8 @@ EZO sensor circuits The ``ezo`` sensor platform allows you to use your EZO sensor circuits with ESPHome. The :ref:`I²C Bus ` is required to be set up in your configuration for this sensor to work. +All embedded solutions from EZO can be found `here `__. +If a certain command is not supported directly, it can be executed with the ``send_custom()`` method call. .. figure:: images/ezo-ph-circuit.png :align: center @@ -43,20 +45,145 @@ Configuration variables: - **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas. - All other options from :ref:`Sensor `. +.. _evo_callbacks: + +Callbacks +--------- + +- **on_led:** : Triggered when the result of ``get_led_state()`` is ready. The LED state is provided as a boolean variable named ``x``. +- **on_device_information:** : Triggered when the result of ``get_device_information()`` is ready. The result is provided as a ``std::string`` variable named ``x``. +- **on_slope:** : Triggered when the result of ``get_slope()`` is ready. The result is provided as a ``std::string`` variable named ``x``. +- **on_calibration:** : Triggered when the result of ``get_calibration()`` is ready. The result is provided as a ``std::string`` variable named ``x``. +- **on_t:** : Triggered when the result of ``get_t()`` is ready. The result is provided as a ``std::string`` variable named ``x``. +- **on_custom:** : Triggered when the result of ``get_custom()`` is ready. The result is provided as a ``std::string`` variable named ``x``. + +.. _evo_lambda_calls: + lambda calls ------------ -From :ref:`lambdas `, you can set the temperature compensation for the -sensors that support that option. +From :ref:`lambdas `, you can interact with the sensor in various ways. For any ``get`` command a trigger will be called with the information retrieved from the sensor. See :ref:`evo_callbacks`. For more information on the command specifics, refer to the datasheet. -- ``set_tempcomp_value()``: Send the given temperature to the sensor. +- ``set_i2c(uint8_t address)``: Set I2C address of the device, must be an integer between 1 and 127 + + .. code-block:: cpp + + id(ph_ezo).set_i2c(100); + + +- ``get_device_information()``: Sensor retrieves calibration and triggers ``on_device_information:`` once done + + .. code-block:: cpp + + id(ph_ezo).get_device_information(); + + +- ``set_sleep()``: Put the device to sleep + + .. code-block:: cpp + + id(ph_ezo).set_sleep(); + + +- ``get_state()``: Performs a read on the current sensor. + + .. code-block:: cpp + + id(ph_ezo).get_state(); + + +- ``get_slope()``: Sensor retrieves slope and triggers ``on_slope:`` once done + + .. code-block:: cpp + + id(ph_ezo).get_slope(); + + +- ``get_t()``: Sensor retrieves temperature compensation value (in Celcius) and triggers ``on_t:`` once done + + .. code-block:: cpp + + id(ph_ezo).get_t(); + + +- ``set_t(float value)``: Send the given temperature (in Celcius) to the sensor. + + .. code-block:: cpp + + id(ph_ezo).set_t("27.00"); + + +- ``set_tempcomp_value(float temp)``: Send the given temperature (in Celcius) to the sensor (this is an alias of `set_t()` for backwards compatibility) .. code-block:: cpp - // Within a lambda, set the temperature compensation value from the temperature sensor id(ph_ezo).set_tempcomp_value(id(rtd_ezo).state); +- ``get_calibration()``: Sensor retrieves calibration and triggers ``on_calibration:`` once done + + .. code-block:: cpp + + id(ph_ezo).get_calibration(); + + +- ``set_calibration_generic(float value)``: Sets the calibration with no point. + + .. code-block:: cpp + + id(ph_ezo).set_calibration_generic(750.0); + + +- ``set_calibration_point_low(float value)``: Sets the low calibration point. + + .. code-block:: cpp + + id(ph_ezo).set_calibration_point_low(4.00); + + +- ``set_calibration_point_mid(float value)``: Sets the medium calibration point. + + .. code-block:: cpp + + id(ph_ezo).set_calibration_point_mid(7.00); + + +- ``set_calibration_point_high(float value)``: Sets the high calibration point. + + .. code-block:: cpp + + id(ph_ezo).set_calibration_point_low(10.00); + + +- ``clear_calibration()``: Clears all calibration points. + + .. code-block:: cpp + + id(ph_ezo).clear_calibration(); + + +- ``get_led_state()``: Sensor LED state and triggers ``on_led:`` once done + + .. code-block:: cpp + + id(ph_ezo).get_led_state(); + + +- ``set_led_state(bool on)``: Sensor LED on or off + + .. code-block:: cpp + + id(ph_ezo).set_led_state(true); + + +- ``send_custom(const std::string &payload, uint16_t delay_ms = 300, bool response_expected = false)``: Runs a custom command. This sends exactly what is in ``payload``. Optionally you can set a ``delay`` and if a response is expected that should be parsed. Defaults to ``false`` for custom commands. Triggers ``on_custom:`` if there's a response. + + .. code-block:: cpp + + // Run a custom command to turn on the LED + id(ph_ezo).send_custom("L,1"); + + See Also --------