Compensation


The Compensation integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] consumes the stateThe state holds the information of interest of an entity, for example, if a light is on or off. Each entity has exactly one state and the state only holds one value at a time. However, entities can store attributes related to that state such as brightness, color, or a unit of measurement. [Learn more] from other sensorsSensors return information about a thing, for instance the level of water in a tank.[Learn more]. It exports the compensated value as state in a separate entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] and the following values as attributes: entity_id and coefficients. A single polynomial, linear by default, is fit to all data points provided.

Configuration

To enable the compensation sensor, add the following lines to your configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI.[Learn more] file. After changing the configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI.[Learn more] file, restart Home Assistant to apply the changes. To view the changes, go to Settings > Devices & services > Entities.

# Example configuration.yaml entry
compensation:
  media_player_db_volume:
    source: media_player.yamaha_receiver
    attribute: volume_level
    unit_of_measurement: dB
    data_points:
      - [0.2, -80.0]
      - [1.0, 0.0]

  media_player_zone_2_db_volume:
    source: media_player.yamaha_receiver_zone_2
    attribute: volume_level
    unit_of_measurement: dB
    # Ensure that the sensor's value will not have a state lower than -80.0
    # when the source sensors value is less than 0.2
    lower_limit: true
    # Ensure that the sensor's value will not have a state greater than 0.0
    # when the source sensors value is greater than 1.0
    upper_limit: true
    data_points:
      - [0.2, -80.0]
      - [1.0, 0.0]

Configuration Variables

source string Required

The entity to monitor/compensate.

data_points list Required

The collection of data point conversions with the format [uncompensated_value, compensated_value]. e.g., [1.0, 2.1]. The number of required data points is equal to the polynomial degree + 1. For example, a linear compensation (with degree: 1) requires at least 2 data points.

unique_id string (Optional)

An ID that uniquely identifies this sensor. Set this to a unique value to allow customization through the UI.

attribute string (Optional)

Attribute from the source to monitor/compensate. When omitted the state value of the source will be used.

degree integer (Optional, default: 1)

The degree of a polynomial. e.g., Linear compensation (y = x + 3) has 1 degree, Quadratic compensation (y = x2 + x + 3) has 2 degrees, etc.

precision integer (Optional, default: 2)

Defines the precision of the calculated values, through the argument of round().

unit_of_measurement string (Optional)

Defines the units of measurement of the sensor, if any.

lower_limit boolean (Optional, default: false)

Enables a lower limit for the sensor. The lower limit is defined by the data collections (data_points) lowest uncompensated_value. For example, if the lowest uncompensated_value value is 1.0 and the paired compensated_value is 0.0, any source state less than 1.0 will produce a compensated state of 0.0.

upper_limit boolean (Optional, default: false)

Enables an upper limit for the sensor. The upper limit is defined by the data collections (data_points) greatest uncompensated_value. For example, if the greatest uncompensated_value value is 5.0 and the paired compensated_value is 10.0, any source state greater than 5.0 will produce a compensated state of 10.0.