Convert to TB

Can someone help me please by conversion (7923563229184) - to tb

.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.115.104.97.114.101.102.114.101.101.10 = STRING: downloads: 7923563229184
{{ ((((7923563229184 / 1024)/1024)/1024)/1024) | round(2) }}

Thanks, that number is changing.

  - platform: snmp
    name: 'UnRAID Backup Folder'
    host: !secret unraid
    port: 161
    community: public
    baseoid: 1.3.6.1.4.1.8072.1.3.2.4.1.2.9.115.104.97.114.101.102.114.101.101.1
    accept_errors: true
    value_template: '{{ (states.sensor.unraid_backup_folder  /1000000000000)|round(1) }}'
    unit_of_measurement: 'TB'

I tried like that :smirk: I did not make it

It might be because states.sensor.unraid_backup_folder is a string, not a value.

try:

value_template: '{{ (states.sensor.unraid_backup_folder | float  /1000000000000)|round(1) }}'

It only shows a numberā€¦

Try another float before the round.

Ah ! Tera Bytes (TB)

No, not another disease tracker :slight_smile:

1 Like

All states are stored as strings, so they need to be converted to a number (float or int) before doing maths.

Can you give an example of what I posted?

What do you mean?

I think the issue this that with that template

value_template: '{{ (states.sensor.unraid_backup_folder | float / 1000000000000)|round(1) }}'

the template is actually based on the previous value of that sensor, rather than the new value, that can be useful (if, for example, you want the old value to be retained if the sensor returns a value of ā€œunknownā€ or null) but isnā€™t what you want here. What you need is actually:

value_template: '{{ (value | float / 1000000000000) | round(1) }}'

Take a look at the examples section for an example showing this.

2 Likes

I was going to mention the general ā€˜slideā€™ of quoting binary numbers in decimal format, but couldnā€™t be bothered explaining it afterward. Well done for taking that one on the chin :+1:

Assuming Iā€™ve got you right there, they did ask for it in TB (terabytes) and not TiB (tebibytes) :slight_smile:

1 Like

Where are the ā€œPeopleā€™s Popular Liberation Frontā€ ?

Oh ! Heā€™s over there !

:rofl: