Convert RPM value to Percentage

Hi everyone, I’m trying to take an RPM value from a server and turn it into a percentage. I have the RPM feeding into a Home Assistant sensor I just need to convert it.

So 0 RPM should be 0% and 20500RPM should be 100% and I can’t figure out how to write a template for this.

I’m really bad at math so I’m hoping someone can help me out here.

Thank you!


  - sensor:
      - name: Fan Speed Percent
        state_class: measurement
        unit_of_measurement: "%"
        icon: "mdi:fan"
        state: "{{ ([0,(states('sensor.fan_rpm')|float / 205 )|round(0),100]|sort)[1] }}"
        availability: "{{ has_value('sensor.fan_rpm') }}"

Replace sensor.fan_rpm with your fan rpm sensor entity_id in both templates.

It looks more complicated than it is.

As you have no offset the calculation is simply:

% = 100 * RPM / 20500

Which can be simplified to:

% = RPM / 205

The rest of the template is converting the state string to a number with|float, rounding it to a whole number with |round(0) and limiting the value to the range 0 to 100 in case your fan rpm ever slightly exceeds 20500, ([0,value,100]|sort)[1]

Worked perfectly! Thank you so much! And also thank you for the explanation!

1 Like