home-assistant.io/source/_integrations/integration.markdown

2.9 KiB

title description ha_category ha_release ha_iot_class ha_quality_scale ha_codeowners ha_domain ha_platforms
Integration - Riemann sum integral Instructions on how to integrate Integration Sensor into Home Assistant.
Utility
Energy
Sensor
0.87 Local Push internal
@dgomes
integration
sensor

The integration platform provides the Riemann sum of the values provided by a source sensor. The Riemann sum is an approximation of an integral by a finite sum. The integration sensors is updated upon changes of the source. Fast sampling source sensors provide better results. In this implementation, the default is the Trapezoidal method, but Left and Right methods can optionally be used.

Configuration

To enable Integration Sensor in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: integration
    source: sensor.current_power

{% configuration %} source: description: The entity ID of the sensor providing numeric readings. required: true type: string name: description: Name to use in the frontend. required: false default: source entity ID meter type: string round: description: Round the calculated integration value to at most N decimal places. required: false default: 3 type: integer unit_prefix: description: "Metric unit to prefix the integration result. Available units are k, M, G and T." required: false default: None type: string unit_time: description: "SI unit of time to integrate over. Available units are s, min, h and d." required: false default: h type: string method: description: "Riemann sum method to be used. Available methods are trapezoidal, left and right." required: false type: string default: trapezoidal {% endconfiguration %}

In case you have an appliance which produces spikey consumption (like an on/off electrical boiler) you should opt for the left method to get accurate readings.

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.

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), then you can use the integration sensor to track how much energy is being spent. Take the next configuration as an example:

sensor:
  - platform: integration
    source: sensor.current_power
    name: energy_spent
    unit_prefix: k
    round: 2

This configuration will provide you with sensor.energy_spent which will have your energy in kWh.