本帖最后由 avrilclc 于 2024-5-16 20:41 编辑
我都是看ppb的,随手用chatgpt写了一个,测试了 可用
如果你有压力传感器的话,还可以加上 return id(jiaquan_ppb).state * 0.1203 * 101 / (273 + T) * 30.026 / 1000; 这里面101就是压力
sensor:
- platform: sfa30
formaldehyde:
name: "Formaldehyde (ppb)"
id: jiaquan_ppb
temperature:
name: "Temperature"
id: wendu
humidity:
name: "Humidity"
id: shidu
- platform: template
name: "Formaldehyde (mg/m³)"
unit_of_measurement: "mg/m³"
accuracy_decimals: 3
lambda: |-
if (isnan(id(jiaquan_ppb).state) || isnan(id(wendu).state)) {
return NAN;
}
const float T = id(wendu).state; // Get the temperature value
return id(jiaquan_ppb).state * 0.1203 * 101 / (273 + T) * 30.026 / 1000;
|