EZO 传感器电路
ezo 传感器平台允许您将 EZO 传感器电路与
ESPHome 配合使用。配置中必须设置 I²C 总线 才能使此传感器工作。
EZO 的所有嵌入式解决方案可在其网站上找到。
如果某个命令不支持直接使用,可通过 send_custom() 方法调用执行。
# 示例配置条目sensor:
- platform: ezo id: ph_ezo address: 99 unit_of_measurement: "pH" update_interval: 10s
- platform: ezo id: rtd_ezo name: "RTD 温度" address: 102 accuracy_decimals: 2 unit_of_measurement: "°C" update_interval: 10s-
address (必选, int): 指定传感器的 I²C 地址。
-
update_interval (可选, Time): 检查传感器的时间间隔。默认为
60s。 -
来自 Sensor 的所有其他选项。
自动化触发器:
-
on_led (可选, Action): 当
get_led_state()的结果就绪时触发。LED 状态作为名为x的布尔变量提供。 -
on_device_information (可选, Action): 当
get_device_information()的结果就绪时触发。结果作为名为x的std::string变量提供。 -
on_slope (可选, Action): 当
get_slope()的结果就绪时触发。结果 作为名为x的std::string变量提供。 -
on_calibration (可选, Action): 当
get_calibration()的结果就绪时触发。 结果作为名为x的std::string变量提供。 -
on_t (可选, Action): 当
get_t()的结果就绪时触发。结果作为 名为x的std::string变量提供。 -
on_custom (可选, Action): 当
get_custom()的结果就绪时触发。结果作为名为x的std::string变量提供。
Lambda 调用
Section titled “Lambda 调用”从 lambda 中,您可以通过多种方式与传感器交互。对于任何 get 命令,都会使用从传感器检索到的信息调用触发器。有关命令具体信息的更多信息,请参阅数据手册。
set_i2c(uint8_t address): 设置设备的 I2C 地址,必须是 1 到 127 之间的整数
id(ph_ezo).set_i2c(100);get_device_information(): 传感器检索校准,完成后触发on_device_information:
id(ph_ezo).get_device_information();set_sleep(): 让设备进入睡眠模式
id(ph_ezo).set_sleep();get_state(): 对当前传感器执行读取。
id(ph_ezo).get_state();get_slope(): 传感器检索斜率,完成后触发on_slope:
id(ph_ezo).get_slope();get_t(): 传感器检索温度补偿值(单位为摄氏度),完成后触发on_t:
id(ph_ezo).get_t();set_t(float value): 将给定温度(单位为摄氏度)发送给传感器。
id(ph_ezo).set_t("27.00");set_tempcomp_value(float temp): 将给定温度(单位为摄氏度)发送给传感器(这是set_t()的别名,用于向后兼容)
id(ph_ezo).set_tempcomp_value(id(rtd_ezo).get_state());get_calibration(): 传感器检索校准,完成后触发on_calibration:
id(ph_ezo).get_calibration();set_calibration_generic(float value): 设置无点的校准。
id(ph_ezo).set_calibration_generic(750.0);set_calibration_point_low(float value): 设置低校准点。
id(ph_ezo).set_calibration_point_low(4.00);set_calibration_point_mid(float value): 设置中校准点。
id(ph_ezo).set_calibration_point_mid(7.00);set_calibration_point_high(float value): 设置高中校准点。
id(ph_ezo).set_calibration_point_high(10.00);clear_calibration(): 清除所有校准点。
id(ph_ezo).clear_calibration();get_led_state(): 传感器 LED 状态,完成后触发on_led:
id(ph_ezo).get_led_state();set_led_state(bool on): 传感器 LED 开或关
id(ph_ezo).set_led_state(true);send_custom(const std::string &payload, uint116_t delay_ms = 300, bool response_expected = false): 运行自定义命令。这会完全发送payload中的内容。可选择设置delay,以及是否需要解析响应。自定义命令默认值为false。如有响应则触发on_custom:。
// 运行自定义命令以打开 LED id(ph_ezo).send_custom("L,1");