How do I remove the following unit of measurement?

Hi All,

I have my snmp platform finally working for my NAS, unfortunately when my disk space sensors return their value it has a “G” or a “T” affixed to the end which is preventing me from being able to get cards such as sensor cards to work correctly.

I have no use of the letter affixed to the end of the result. How can I go about removing this at home assistants end?

Thank you!

I don’t know if you can configure the snmp integration to show no unit of measurement, you can however create a template sensor that strips off the last letter. Use @petro’s solution.

2 Likes

if it’s the last letter, just remove the last item in the snmp value_template:

{{ value[:-1] }}

Edit: more clear answer:

  - platform: snmp
    host: !secret unifi_bonus_switch
    name: Bonus Room Switch Uptime
    baseoid: 1.3.6.1.2.1.1.3.0
    value_template: "{{ value[:-1] }}"
    unit_of_measurement: T

Last edit I swear.

You may need to conditionally check for T vrs G and multiply or divide by 1000 depending on the result. It’s why they have a unit.

2 Likes

Thank you! @petro

Exactly what I was looking for and with the additional information that I will need going forward in order to measure appropriately!

Thanks again