mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Introduce unit enums for information and data rate (#83291)
* Introduce UnitOfData enum * Introduce UnitOfDataRate enum * UnitOfData > UnitOfInformation
This commit is contained in:
parent
7eda67be11
commit
67192d4ea7
@ -873,41 +873,117 @@ SPEED_INCHES_PER_HOUR: Final = "in/h"
|
||||
SIGNAL_STRENGTH_DECIBELS: Final = "dB"
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT: Final = "dBm"
|
||||
|
||||
|
||||
# Data units
|
||||
class UnitOfInformation(StrEnum):
|
||||
"""Information units."""
|
||||
|
||||
BITS = "bit"
|
||||
KILOBITS = "kbit"
|
||||
MEGABITS = "Mbit"
|
||||
GIGABITS = "Gbit"
|
||||
BYTES = "B"
|
||||
KILOBYTES = "kB"
|
||||
MEGABYTES = "MB"
|
||||
GIGABYTES = "GB"
|
||||
TERABYTES = "TB"
|
||||
PETABYTES = "PB"
|
||||
EXABYTES = "EB"
|
||||
ZETTABYTES = "ZB"
|
||||
YOTTABYTES = "YB"
|
||||
KIBIBYTES = "KiB"
|
||||
MEBIBYTES = "MiB"
|
||||
GIBIBYTES = "GiB"
|
||||
TEBIBYTES = "TiB"
|
||||
PEBIBYTES = "PiB"
|
||||
EXBIBYTES = "EiB"
|
||||
ZEBIBYTES = "ZiB"
|
||||
YOBIBYTES = "YiB"
|
||||
|
||||
|
||||
DATA_BITS: Final = "bit"
|
||||
"""Deprecated: please use UnitOfInformation.BITS"""
|
||||
DATA_KILOBITS: Final = "kbit"
|
||||
"""Deprecated: please use UnitOfInformation.KILOBITS"""
|
||||
DATA_MEGABITS: Final = "Mbit"
|
||||
"""Deprecated: please use UnitOfInformation.MEGABITS"""
|
||||
DATA_GIGABITS: Final = "Gbit"
|
||||
"""Deprecated: please use UnitOfInformation.GIGABITS"""
|
||||
DATA_BYTES: Final = "B"
|
||||
"""Deprecated: please use UnitOfInformation.BYTES"""
|
||||
DATA_KILOBYTES: Final = "kB"
|
||||
"""Deprecated: please use UnitOfInformation.KILOBYTES"""
|
||||
DATA_MEGABYTES: Final = "MB"
|
||||
"""Deprecated: please use UnitOfInformation.MEGABYTES"""
|
||||
DATA_GIGABYTES: Final = "GB"
|
||||
"""Deprecated: please use UnitOfInformation.GIGABYTES"""
|
||||
DATA_TERABYTES: Final = "TB"
|
||||
"""Deprecated: please use UnitOfInformation.TERABYTES"""
|
||||
DATA_PETABYTES: Final = "PB"
|
||||
"""Deprecated: please use UnitOfInformation.PETABYTES"""
|
||||
DATA_EXABYTES: Final = "EB"
|
||||
"""Deprecated: please use UnitOfInformation.EXABYTES"""
|
||||
DATA_ZETTABYTES: Final = "ZB"
|
||||
"""Deprecated: please use UnitOfInformation.ZETTABYTES"""
|
||||
DATA_YOTTABYTES: Final = "YB"
|
||||
"""Deprecated: please use UnitOfInformation.YOTTABYTES"""
|
||||
DATA_KIBIBYTES: Final = "KiB"
|
||||
"""Deprecated: please use UnitOfInformation.KIBIBYTES"""
|
||||
DATA_MEBIBYTES: Final = "MiB"
|
||||
"""Deprecated: please use UnitOfInformation.MEBIBYTES"""
|
||||
DATA_GIBIBYTES: Final = "GiB"
|
||||
"""Deprecated: please use UnitOfInformation.GIBIBYTES"""
|
||||
DATA_TEBIBYTES: Final = "TiB"
|
||||
"""Deprecated: please use UnitOfInformation.TEBIBYTES"""
|
||||
DATA_PEBIBYTES: Final = "PiB"
|
||||
"""Deprecated: please use UnitOfInformation.PEBIBYTES"""
|
||||
DATA_EXBIBYTES: Final = "EiB"
|
||||
"""Deprecated: please use UnitOfInformation.EXBIBYTES"""
|
||||
DATA_ZEBIBYTES: Final = "ZiB"
|
||||
"""Deprecated: please use UnitOfInformation.ZEBIBYTES"""
|
||||
DATA_YOBIBYTES: Final = "YiB"
|
||||
"""Deprecated: please use UnitOfInformation.YOBIBYTES"""
|
||||
|
||||
|
||||
# Data_rate units
|
||||
class UnitOfDataRate(StrEnum):
|
||||
"""Data rate units."""
|
||||
|
||||
BITS_PER_SECOND = "bit/s"
|
||||
KILOBITS_PER_SECOND = "kbit/s"
|
||||
MEGABITS_PER_SECOND = "Mbit/s"
|
||||
GIGABITS_PER_SECOND = "Gbit/s"
|
||||
BYTES_PER_SECOND = "B/s"
|
||||
KILOBYTES_PER_SECOND = "kB/s"
|
||||
MEGABYTES_PER_SECOND = "MB/s"
|
||||
GIGABYTES_PER_SECOND = "GB/s"
|
||||
KIBIBYTES_PER_SECOND = "KiB/s"
|
||||
MEBIBYTES_PER_SECOND = "MiB/s"
|
||||
GIBIBYTES_PER_SECOND = "GiB/s"
|
||||
|
||||
|
||||
DATA_RATE_BITS_PER_SECOND: Final = "bit/s"
|
||||
"""Deprecated: please use UnitOfDataRate.BITS_PER_SECOND"""
|
||||
DATA_RATE_KILOBITS_PER_SECOND: Final = "kbit/s"
|
||||
"""Deprecated: please use UnitOfDataRate.KILOBITS_PER_SECOND"""
|
||||
DATA_RATE_MEGABITS_PER_SECOND: Final = "Mbit/s"
|
||||
"""Deprecated: please use UnitOfDataRate.MEGABITS_PER_SECOND"""
|
||||
DATA_RATE_GIGABITS_PER_SECOND: Final = "Gbit/s"
|
||||
"""Deprecated: please use UnitOfDataRate.GIGABITS_PER_SECOND"""
|
||||
DATA_RATE_BYTES_PER_SECOND: Final = "B/s"
|
||||
"""Deprecated: please use UnitOfDataRate.BYTES_PER_SECOND"""
|
||||
DATA_RATE_KILOBYTES_PER_SECOND: Final = "kB/s"
|
||||
"""Deprecated: please use UnitOfDataRate.KILOBYTES_PER_SECOND"""
|
||||
DATA_RATE_MEGABYTES_PER_SECOND: Final = "MB/s"
|
||||
"""Deprecated: please use UnitOfDataRate.MEGABYTES_PER_SECOND"""
|
||||
DATA_RATE_GIGABYTES_PER_SECOND: Final = "GB/s"
|
||||
"""Deprecated: please use UnitOfDataRate.GIGABYTES_PER_SECOND"""
|
||||
DATA_RATE_KIBIBYTES_PER_SECOND: Final = "KiB/s"
|
||||
"""Deprecated: please use UnitOfDataRate.KIBIBYTES_PER_SECOND"""
|
||||
DATA_RATE_MEBIBYTES_PER_SECOND: Final = "MiB/s"
|
||||
"""Deprecated: please use UnitOfDataRate.MEBIBYTES_PER_SECOND"""
|
||||
DATA_RATE_GIBIBYTES_PER_SECOND: Final = "GiB/s"
|
||||
"""Deprecated: please use UnitOfDataRate.GIBIBYTES_PER_SECOND"""
|
||||
|
||||
|
||||
# #### SERVICES ####
|
||||
|
Loading…
x
Reference in New Issue
Block a user