GiB to TB convert - template?

I’ve got a sensor which reports values in GiB.
I need to convert this to GB or TB.

There is a formula for this, but can this also be done with a template for instance?


Of course:

  - sensor:
      - name: Storage
        state: "{{ states('sensor.YOUR_GiB_ENTITY')|float(0) * 0.001073741824 }}"
        unit_of_measurement: 'TB'
        device_class: data_size

You can create this in the UI: just put the {{ ... }} bit in the template field.

Given that I’ve just provided very similar advice for your load average sensor — could you not have worked this out yourself?

I think too much about things like this, can be as simple like this

See this sticky post, particularly sections 1, 4 and 9: