Round() returns null?

My Goal is to convert and entity attribute output from GiB to TB

The entity attribute state returns 10940.1 GiB I understand this is most likely a string so I’ve split it and isolated just the number with

{{ states.sensor.pinewood_volume_used_qnap.attributes['Volume Size'].split(" ")[0] }}

which outputs 10940.1

But when I add the round() function to my formula below it returns 0. Otherwise if I remove the round() function it works but it returns 11.746735554559999 and I’m trying to convert this to a whole number. This is what I’ve got so far:

{{ states.sensor.pinewood_volume_used_qnap.attributes['Volume Size'].split(" ")[0] | int *0.001073741824 | round() }}

It’s probably something simple…any help is appreciated.

This is an precedence of operators issue. Filters have precedence over multiplication so the round() is only being applied to 0.001073741824… You are effectively multiplying the size by 0.

Use parentheses to apply the rounding to the results from the multiplication:

{{ (state_attr('sensor.pinewood_volume_used_qnap', 'Volume Size').split(' ')[0] | int(0) *0.001073741824) | round() }}

That makes more sense now. Gosh, thanks so much.