Core: 0.111.0 File size sensor calculation error

Created on 12 Jun 2020  路  6Comments  路  Source: home-assistant/core

The problem

File size in MB is wrongly calculated. See attached screenshot where bytes and MB are the same value.

Correct formula should be "total bytes / 1024 / 1024".

Environment

  • Home Assistant Core release with the issue: 0.111.0
  • Last working Home Assistant Core release (if known):
  • Operating environment (Home Assistant/Supervised/Docker/venv): Docker
  • Integration causing this issue: filesize
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

- platform: filesize
  file_paths:
    - /config/home-assistant_v2.db

Traceback/Error logs

-

Additional information

image

filesize stale

Most helpful comment

I am working on adding that support. I already implemented a new data_size HA util that can convert between any SI and IEC data unit and added an optional parameter to the configuration for the user to set for the filesize integration. More details in the PR I am going to create soon.

All 6 comments

filesize documentation
filesize source
(message by IssueLinks)

Depends on who you ask I would say; If one follows the internal system of units (SI), the current is actually correct. Furthermore, your given calculation refers to the binary prefix, which is expressed as MiB, not MB.

Good point, even if most system still use 2^20 for files size and instead use 10^6 for network related calculations.

I ca easily solve using a custom sensor, but I think "MiB" should be added as attribute so nobody would have any doughs in future ;-)

Simone

I am working on adding that support. I already implemented a new data_size HA util that can convert between any SI and IEC data unit and added an optional parameter to the configuration for the user to set for the filesize integration. More details in the PR I am going to create soon.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

There is a PR that is ready to be merged; only issue is that is based on yaml.

Simone

Was this page helpful?
0 / 5 - 0 ratings

Related issues

piitaya picture piitaya  路  3Comments

kirichkov picture kirichkov  路  3Comments

missedtheapex picture missedtheapex  路  3Comments

Elmardus picture Elmardus  路  3Comments

TheZoker picture TheZoker  路  3Comments