# Body fat calculation Mi Smart Scale 2

Hi Everyone,

I am trying to use the following formula to calculate body fat using, impedance, weight, age, height and gender:

https://www.brianmac.co.uk/fatbia.htm

``````Calculation of Body Fat %

Lukaski & Bolonchuk's (1988)[1] formula for total body water (TBW) is:

TBW = 0.372(S²÷R) + 3.05(Sex) + 0.142(W) - 0.069(age)

S = Height in centimetres
R = Resistance
W = Weight in Kg
Sex Male =1 Female = 0
Age in years
``````

I am using the following template but am not sure its very accurate. Any ideas?

``````{%- set impedence = states('sensor.impedance_adam') | float %}
{%- set weight = states('sensor.weight_adam') | float %}
{%- set age = 33 %}
{%- set height = 170 %}
{%- set gender = 1 %}

{%- set water_weight = 0.372 * ((height*height) / impedence) + (3.05 * gender) + (0.142 * weight) - (0.069 *age) %}
{%- set fat_free_weight = water_weight / 0.73  %}
{%- set fat_weight = weight - fat_free_weight  %}
{%- set fat_percent = fat_weight / weight * 100 %}
{{ fat_percent | round(1)}}
``````

This HACS integration may do what you want for you. I’ve not used it, but you point it at your weight and impedance sensors and it creates the others for you.