跳转到内容

积分传感器

integration 传感器是一种辅助传感器,可以随时间对其他传感器的值进行积分。例如,这可以用于对水流传感器(单位为 m^3/s)的值随时间进行积分(结果单位为 m^3)。

此组件可以视为 Total Daily Energy 的更通用版本。

# Example configuration entry
sensor:
- platform: integration
name: "Total Daily Energy"
sensor: my_flow_meter
time_unit: min
# The sensor to integrate, can be any power sensor
- platform: pulse_counter
# ...
id: my_flow_meter
  • sensor(必选,ID): 要随时间积分的传感器的 ID。

  • time_unit(必选,string): 积分所用的时间单位,可选值为 ms、s、min、h 或 d。

  • integration_method (可选,string): 使用的积分方法。可选值为 trapezoid、left 或 right。默认为 trapezoid。

  • restore (可选,boolean): 是否在设备上存储中间结果,以便 在断电或重启后恢复该值。 警告:此选项可能导致闪存磨损。默认为 false。

  • 来自 Sensor 的其他所有选项。

此操作允许您将积分传感器的值 重置为零。例如,可以通过 基于时间的自动化在午夜将积分传感器重置为零。

on_...:
- sensor.integration.reset: my_integration_sensor

此操作允许您将积分传感器设置为特定值。 例如,可以在电池完全充满时将其设置为电池容量。

on_...:
- sensor.integration.set_value:
id: my_integration_sensor
value: 100

配置选项:

  • id(必选,ID): 积分传感器的 ID。
  • value(必选,float,可模板化): 要设置的积分传感器值。