Integral
This integration provides the Riemann sum
The integration sensors are updated whenever the source changes and, optionally, based on a predefined time interval. Source sensors with higher sampling frequency provide more accurate results.
配置
要将 Integral helper 添加到您的 Home Assistant 实例中,请使用此 My 按钮:
手动配置步骤
如果上述 My 按钮不起作用,您也可以手动执行以下步骤:
-
浏览到您的 Home Assistant 实例。
-
转到
设置 > 设备与服务。 -
在屏幕顶部,选择标签:Helpers。
-
在右下角,选择
创建助手 按钮。 -
从列表中选择 Integral。
-
按照屏幕上的说明完成设置。
YAML configuration
Alternatively, this integration can be configured and set up manually via YAML
as well. To enable the Integration sensor in your installation, add the
following to your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file:
# Example configuration.yaml entry
sensor:
- platform: integration
source: sensor.current_power
Configuration Variables
An ID that uniquely identifies the integration sensor. Set this to a unique value to allow customization through the UI.
Round the calculated integration value to at most N decimal places.
Metric unit to prefix the integration result. Available units are k
, M
, G
and T
.
SI unit of time to integrate over. Available units are s
, min
, h
and d
.
Riemann sum method to be used. Available methods are trapezoidal
, left
and right
.
The unit of source
together with unit_prefix
and unit_time
is used to generate a unit for the integral product (e.g. a source in W
with prefix k
and time h
would result in kWh
). Note that unit_prefix
and unit_time
are also relevant to the Riemann sum calculation.
Integration method
The Riemann Sum is an approximation of an integral by a finite sum and is therefore intrinsically inaccurate. Nonetheless, depending on the method used, values can be more or less accurate.
The integration method defines how to calculate the area under the source sensor when it changes. Regardless of the method used, the integration will be more accurate if the source updates more often. The config max_sub_interval
can be used to trigger integration when the source sensor is constant.
Trapezoidal
The trapezoidal
method follows the Trapezoidal rule
Left
The left
method follows the Left ruletrapezoidal
.
Right
The right
method follows the Right rule
Energy
An integration sensor is quite useful in energy billing scenarios since energy is generally billed in kWh and many sensors provide power in W (Watts).
If you have a sensor that provides you with power readings in Watts (uses W as unit_of_measurement
, device_class
of power
), then you can use the integration
sensor to track how much energy is being spent. Take the next manual YAML configuration as an example:
sensor:
- platform: integration
source: sensor.current_power
name: energy_spent
unit_prefix: k
round: 2
max_sub_interval:
minutes: 5
This configuration will provide you with sensor.energy_spent
which will have your energy in kWh, as a device_class
of energy
.