Home Assistant Unofficial Reference 2024.12.1
homeassistant.util.unit_system.UnitSystem Class Reference

Public Member Functions

None __init__ (self, str name, *UnitOfPrecipitationDepth accumulated_precipitation, UnitOfArea area, dict[tuple[SensorDeviceClass|str|None, str|None], str] conversions, UnitOfLength length, UnitOfMass mass, UnitOfPressure pressure, UnitOfTemperature temperature, UnitOfVolume volume, UnitOfSpeed wind_speed)
 
float accumulated_precipitation (self, float|None precip, str from_unit)
 
float area (self, float|None area, str from_unit)
 
dict[str, str] as_dict (self)
 
str|None get_converted_unit (self, SensorDeviceClass|str|None device_class, str|None original_unit)
 
float length (self, float|None length, str from_unit)
 
float pressure (self, float|None pressure, str from_unit)
 
float temperature (self, float temperature, str from_unit)
 
float volume (self, float|None volume, str from_unit)
 
float wind_speed (self, float|None wind_speed, str from_unit)
 

Public Attributes

 accumulated_precipitation_unit
 
 area_unit
 
 length_unit
 
 mass_unit
 
 pressure_unit
 
 temperature_unit
 
 volume_unit
 
 wind_speed_unit
 

Private Attributes

 _conversions
 
 _name
 

Detailed Description

A container for units of measure.

Definition at line 85 of file unit_system.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.util.unit_system.UnitSystem.__init__ (   self,
str  name,
*UnitOfPrecipitationDepth  accumulated_precipitation,
UnitOfArea  area,
dict[tuple[SensorDeviceClass | str | None, str | None], str]  conversions,
UnitOfLength  length,
UnitOfMass  mass,
UnitOfPressure  pressure,
UnitOfTemperature  temperature,
UnitOfVolume  volume,
UnitOfSpeed  wind_speed 
)
Initialize the unit system object.

Definition at line 88 of file unit_system.py.

Member Function Documentation

◆ accumulated_precipitation()

float homeassistant.util.unit_system.UnitSystem.accumulated_precipitation (   self,
float | None  precip,
str  from_unit 
)
Convert the given length to this unit system.

Definition at line 151 of file unit_system.py.

◆ area()

float homeassistant.util.unit_system.UnitSystem.area (   self,
float | None  area,
str  from_unit 
)
Convert the given area to this unit system.

Definition at line 161 of file unit_system.py.

◆ as_dict()

dict[str, str] homeassistant.util.unit_system.UnitSystem.as_dict (   self)
Convert the unit system to a dictionary.

Definition at line 201 of file unit_system.py.

◆ get_converted_unit()

str | None homeassistant.util.unit_system.UnitSystem.get_converted_unit (   self,
SensorDeviceClass | str | None  device_class,
str | None  original_unit 
)
Return converted unit given a device class or an original unit.

Definition at line 214 of file unit_system.py.

◆ length()

float homeassistant.util.unit_system.UnitSystem.length (   self,
float | None  length,
str  from_unit 
)
Convert the given length to this unit system.

Definition at line 141 of file unit_system.py.

◆ pressure()

float homeassistant.util.unit_system.UnitSystem.pressure (   self,
float | None  pressure,
str  from_unit 
)
Convert the given pressure to this unit system.

Definition at line 171 of file unit_system.py.

◆ temperature()

float homeassistant.util.unit_system.UnitSystem.temperature (   self,
float  temperature,
str  from_unit 
)
Convert the given temperature to this unit system.

Definition at line 132 of file unit_system.py.

◆ volume()

float homeassistant.util.unit_system.UnitSystem.volume (   self,
float | None  volume,
str  from_unit 
)
Convert the given volume to this unit system.

Definition at line 191 of file unit_system.py.

◆ wind_speed()

float homeassistant.util.unit_system.UnitSystem.wind_speed (   self,
float | None  wind_speed,
str  from_unit 
)
Convert the given wind_speed to this unit system.

Definition at line 181 of file unit_system.py.

Member Data Documentation

◆ _conversions

homeassistant.util.unit_system.UnitSystem._conversions
private

Definition at line 130 of file unit_system.py.

◆ _name

homeassistant.util.unit_system.UnitSystem._name
private

Definition at line 121 of file unit_system.py.

◆ accumulated_precipitation_unit

homeassistant.util.unit_system.UnitSystem.accumulated_precipitation_unit

Definition at line 122 of file unit_system.py.

◆ area_unit

homeassistant.util.unit_system.UnitSystem.area_unit

Definition at line 123 of file unit_system.py.

◆ length_unit

homeassistant.util.unit_system.UnitSystem.length_unit

Definition at line 124 of file unit_system.py.

◆ mass_unit

homeassistant.util.unit_system.UnitSystem.mass_unit

Definition at line 125 of file unit_system.py.

◆ pressure_unit

homeassistant.util.unit_system.UnitSystem.pressure_unit

Definition at line 126 of file unit_system.py.

◆ temperature_unit

homeassistant.util.unit_system.UnitSystem.temperature_unit

Definition at line 127 of file unit_system.py.

◆ volume_unit

homeassistant.util.unit_system.UnitSystem.volume_unit

Definition at line 128 of file unit_system.py.

◆ wind_speed_unit

homeassistant.util.unit_system.UnitSystem.wind_speed_unit

Definition at line 129 of file unit_system.py.


The documentation for this class was generated from the following file: