I’m using a template to adjust some sensor values, it is working as expected with the catch that it rounds to the 15th decimal. Suggestions from searching don’t seem to do anything other than break the template, any way to round to two decimal points? Thank you!
Hello I am trying to solve this same issue. I have another sensor template in my yaml file so it’s saying duplacated sensors. How do I add more than one sensor template using two diff. Entities? I’m sure it’s something to do with spacing ?
The pipe ( | ) operator is very low on the order of operations so your template as written is only rounding the divisor of your formula. Put another set of parentheses around the whole thing and you’ll get what you want.
{{ ((127775277056 - value | int * 4096) / 1073741824) | round(1) }}
Please help
I’ve converted MB to TB
and I get this 142735360 using this code.
template:
- sensor:
- name: "D Drive Available Space"
unit_of_measurement: "TB"
state: "{{ states('sensor.kelvin_storage_d_available_space') | float * 1024 | round(1) }} "
The question is how do I round it down to 1 TB?
Another thing I didn’t notice the first time: The pipe (|) is a higher-order operator than the division (/) or multiply (*) operators, so the last bit of your template (and mine) “1024 | round(1)” would only round the integer 1024 to one decimal place, which of course it was already. If you want the result to be rounded, you’d have to put the whole thing in parentheses:
Hi, thanks for your input, and looking at it for me, I have entered the template and the result I am getting is 0.1 it should be 1.0 as its a 1 TB hard drive.
I don’t know what exactly your sensors are intended to be, but “available space” seems to be the space that has not yet been used, not the total space. Could this be accurate? Could the drive have 0.1 Terabytes free? Judging from the value you included in the original question, I think it should have about 140 Gb free. Am I right?
Either this sensor doesn’t mean what you think it does, or the sensor is off by a factor of 10. The calculation itself is pretty straightforward.
I was reading it wrong its available space.
So what I have done is taken out one of the 1024 which give me 136.1
which is what I have left on that drive.