Custom input value

Hi, searched around without luck and need help with a thing.
I had build some easy voltage meter to monitor ups backups and other 12v things, just 2 resistors and a capacitor. The output value is around 1v and using the code below to upscale it to 12v.

   sensors:
   radio_ps_volts_calc2:
    friendly_name: "Ups_Batteri"
    unit_of_measurement: 'volts'
    value_template: "{{ ((states('sensor.ups_router_voltage_2')|float -0.005 ) * 3.35 * 5)|round (1) }}"

The problem is the 12v value isnt linaer with the real 12v sourse, after some adjustment I got 14,2v instead of 13.9 and 11,8v instead of 12,0v. Is it possible to create a curve so the value in HA is same as the real value?

You can use the compensation integration to achieve such a result.

Thanks, just what I wanted. But cant get it to work, trying in template tester but it give me no value. “sensor.ups_router_voltage_2” is my input value.

compensation:
  ups-router_voltage:
    source: sensor.ups_router_voltage_2
    attribute: volume_level
    unit_of_measurement: dB
    data_points:
      - [0.2, -80.0]
      - [1.0, 0.0]

Does sensor.ups_router_voltage_2 really have an attribute called volume_level?
The sensor name kind of says it reads the voltage, not decibel unit_of_measurement: dB

No, it read voltage. But I thought the template dont care if it measure voltage or db, it just convert a value and show it with a unit.
Just copypaste from the example code and changed the input value with my to test if it works

Now it works, the template tester not work with this code. Paste it in again to configuration.yaml and this time delete the attribute line, now it works perfekt