Arduino and MQTT data

Hi There,
Have some pressure sensors in my pool which are transmitting data from an Arduino via MQTT to HASS. I am curious where is the suggested place to perform math and calibration functions?
The raw sensor data is simply a voltage reading, there is some maths to convert this to KPA.
As there are 3x sensors each requires it’s own offset value.
Maths is pretty straightforward:
Offset = 0.483 (or whatever you tested 0 pressure at)
V = SensorVal * 5.00 / 1024
Pressure = (V-Offset) * 250

I have attempted to do this in developer tools / templates but still learning the ropes on how to put a complete math formula in one line:

{% set val = states('sensor.pressuretesting_filter') %}


{% set val = states('sensor.pressuretesting_filter') %}

foo = {{val}}

Pressure sensor value is {{states('sensor.pressuretesting_filter')}}

Pressure sensor value x 5 is {{val | float * 5 }}
{% set newVal = val | float * 5 / 1024 - 0.470 %}
{% set finalVal = newVal | float * 250 %}
New value is {{ newVal}}
Final value is {{finalVal}}

You don’t have to put it all in one line but you can do it like this:

Offset = 0.483 
V = SensorVal * 5.00 / 1024
Pressure = (V-Offset) * 250

{{((states('sensor.pressuretesting_filter') | float * 5 / 1024) - 0.483) * 250}}

or if you want to keep the changing offset as a variable and not change the main formula like this:

Offset = 0.483 
V = SensorVal * 5.00 / 1024
Pressure = (V-Offset) * 250

{% set offset = 0.483 %}
{{((states('sensor.pressuretesting_filter') | float * 5 / 1024) - offset) * 250}}

there are a couple of parenthesis in there that aren’t required because the formula rules takes care of it automatically following order of operations so it can really be reduced a bit to this:

{% set offset = 0.483 %}
{{(states('sensor.pressuretesting_filter') | float * 5 / 1024 - offset) * 250}}

Thanks finity, that’s helpful, will keep working on it.
Cheers Isaac