|
21 | 21 | CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, |
22 | 22 | CONCENTRATION_PARTS_PER_MILLION, |
23 | 23 | CONF_UNIT_OF_MEASUREMENT, |
24 | | - FREQUENCY_GIGAHERTZ, |
| 24 | + LIGHT_LUX, |
25 | 25 | PERCENTAGE, |
26 | | - POWER_VOLT_AMPERE, |
27 | 26 | POWER_VOLT_AMPERE_REACTIVE, |
28 | | - PRESSURE_HPA, |
29 | 27 | SIGNAL_STRENGTH_DECIBELS, |
30 | | - VOLUME_CUBIC_METERS, |
| 28 | + UnitOfApparentPower, |
| 29 | + UnitOfElectricCurrent, |
| 30 | + UnitOfElectricPotential, |
| 31 | + UnitOfEnergy, |
| 32 | + UnitOfFrequency, |
| 33 | + UnitOfPower, |
| 34 | + UnitOfPressure, |
| 35 | + UnitOfVolume, |
31 | 36 | ) |
32 | 37 | from homeassistant.helpers.entity import Entity |
33 | 38 | from homeassistant.helpers.typing import HomeAssistantType |
|
59 | 64 | }) |
60 | 65 |
|
61 | 66 | UNITS_OF_MEASUREMENT = { |
62 | | - SensorDeviceClass.APPARENT_POWER: POWER_VOLT_AMPERE, # apparent power (VA) |
| 67 | + SensorDeviceClass.APPARENT_POWER: UnitOfApparentPower.VOLT_AMPERE, # apparent power (VA) |
63 | 68 | SensorDeviceClass.BATTERY: PERCENTAGE, # % of battery that is left |
64 | 69 | SensorDeviceClass.CO: CONCENTRATION_PARTS_PER_MILLION, # ppm of CO concentration |
65 | 70 | SensorDeviceClass.CO2: CONCENTRATION_PARTS_PER_MILLION, # ppm of CO2 concentration |
66 | 71 | SensorDeviceClass.HUMIDITY: PERCENTAGE, # % of humidity in the air |
67 | | - SensorDeviceClass.ILLUMINANCE: "lm", # current light level (lx/lm) |
| 72 | + SensorDeviceClass.ILLUMINANCE: LIGHT_LUX, # current light level (lx/lm) |
68 | 73 | SensorDeviceClass.NITROGEN_DIOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen dioxide |
69 | 74 | SensorDeviceClass.NITROGEN_MONOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen monoxide |
70 | 75 | SensorDeviceClass.NITROUS_OXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen oxide |
|
75 | 80 | SensorDeviceClass.SIGNAL_STRENGTH: SIGNAL_STRENGTH_DECIBELS, # signal strength (dB/dBm) |
76 | 81 | SensorDeviceClass.SULPHUR_DIOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of sulphur dioxide |
77 | 82 | SensorDeviceClass.TEMPERATURE: "C", # temperature (C/F) |
78 | | - SensorDeviceClass.PRESSURE: PRESSURE_HPA, # pressure (hPa/mbar) |
79 | | - SensorDeviceClass.POWER: "kW", # power (W/kW) |
80 | | - SensorDeviceClass.CURRENT: "A", # current (A) |
81 | | - SensorDeviceClass.ENERGY: "kWh", # energy (Wh/kWh/MWh) |
82 | | - SensorDeviceClass.FREQUENCY: FREQUENCY_GIGAHERTZ, # energy (Hz/kHz/MHz/GHz) |
| 83 | + SensorDeviceClass.PRESSURE: UnitOfPressure.HPA, # pressure (hPa/mbar) |
| 84 | + SensorDeviceClass.POWER: UnitOfPower.KILO_WATT, # power (W/kW) |
| 85 | + SensorDeviceClass.CURRENT: UnitOfElectricCurrent.AMPERE, # current (A) |
| 86 | + SensorDeviceClass.ENERGY: UnitOfEnergy.KILO_WATT_HOUR, # energy (Wh/kWh/MWh) |
| 87 | + SensorDeviceClass.FREQUENCY: UnitOfFrequency.GIGAHERTZ, # energy (Hz/kHz/MHz/GHz) |
83 | 88 | SensorDeviceClass.POWER_FACTOR: PERCENTAGE, # power factor (no unit, min: -1.0, max: 1.0) |
84 | 89 | SensorDeviceClass.REACTIVE_POWER: POWER_VOLT_AMPERE_REACTIVE, # reactive power (var) |
85 | 90 | SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of vocs |
86 | | - SensorDeviceClass.VOLTAGE: "V", # voltage (V) |
87 | | - SensorDeviceClass.GAS: VOLUME_CUBIC_METERS, # gas (m³) |
| 91 | + SensorDeviceClass.VOLTAGE: UnitOfElectricPotential.VOLT, # voltage (V) |
| 92 | + SensorDeviceClass.GAS: UnitOfVolume.CUBIC_METERS, # gas (m³) |
88 | 93 | } |
89 | 94 |
|
90 | 95 |
|
|
0 commit comments