Calibrate Sensor

The ability to calibrate (temperature, humidity, pressure…) sensor values. Without the need for an additional template sensor, to state the obvious.

ESPHome already has this ability:

And additionally a shutter / cover.

press vote to vote

It would be fantastic. Just voted.

1 Like

HI Petro, this was merged recently? Where can we find docs on the integration, Id really like to try and use some calibration on a set of temp sensors

1 Like

It’s in 2021.5.0+

4 Likes

ok running beta 2021.5b01 now, cant find the new integration though. Didn’t it get merged in time?

found it… wasn’t called calibration, but compensation :wink:

now, how to configure a core Hue temp sensor and add 1.7 degrees C to it. To them all…

Right now I use

      front_room_sensor_calibrated_temperature:
        friendly_name: Front room calibr temp
        value_template: >
          {{(states('sensor.front_room_sensor_temperature')|float +
             states('input_number.temp_calibration')|float)|round(2)}}

but I am confused on the config setting in the docs. Could you please help me out here?

compensation:
  front_room_sensor_calibrated_temperature:
    source: sensor.front_room_sensor_temperature
    data_points:
      - [1, 2.7]

and guess no template support for now just yet?

It’s a linear model, give it 2 data points and it does the math for you. It does not support templates in the datapoints because the polynomial in the background would have to change on the fly and validate bad data which would lead to all sorts of problems.

The likely hood of adding templates to this is extremely low.

To be quite honest, you don’t need to use the compensation integration for your equation. Your equation is a flat 1.7 increase or offset. The compensation integration is for non-linear calibrations or hard-to-generate template equations. Like converting decibels to home assistants internal volume values.

Anyways, if you REALLY want to use it, add a second datapoint with a 1.7 offset.

compensation:
  front_room_sensor_calibrated_temperature:
    unique_id: front_room_sensor_calibrated_temperature
    source: sensor.front_room_sensor_temperature
    data_points:
      - [0, 1.7]
      - [1, 2.7]

I see, thanks, will test that.

Hey. What would you use instead of compensate? I also have a temperature sensor that is consistently 3 degrees out.

Just subtract 3 in a template sensor

Thank Petro. If you have a moment would you be able to point me in the right direction for this. Templates is something I’m yet to swat up on. Have looked at the main Template page but need a bit of a steer. Thanks.

platform: template
sensors:
  corrected_temperature:
    friendly_name: "Corrected Temperature"
    value_template: "{{ states('sensor.temperature') | float - 3 }}"

what would I use to convert a negative temperature to a non-negative temperature?
Also where do I place these ‘templates’ or ‘compensations’ so they’ll effect the reading output by the sensor directly? Does it go in the configuration.yaml?

Sorry I’m new to this, still kinda frustrated that I couldn’t just adjust the actual output of my HSM200 to be normal (instead of “correct, but negative for some reason” like it is now)
[The room is 62℉ but it reports -62℉]

Yes, it goes (normally) in configuration.yaml.

1 Like

“compensation” is not the solution because it creates a new sensor and this is sth. I don’t want. This is fine for one sensor, but people won’t duplicate 10 or 20 sensors just to adjust their measurements.
A real solution has to correct the sensor value without changing the sensor itself.

2 Likes

That’s not how HA is designed. Every integration adds a new sensor.

Yes you are right.
And therefore the calibration of sensors must be implemented as a sensor customization in customize.yaml.

The mechanism doesn’t exist, so either use the compensation integration or wait 10 years for the other option to be implemented. What you’re asking for isn’t possible within the current architecture of HA.

1 Like