|
8 | 8 | import voluptuous as vol |
9 | 9 |
|
10 | 10 | from homeassistant.const import ( |
| 11 | + CONCENTRATION_GRAMS_PER_CUBIC_METER, |
11 | 12 | CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, |
12 | 13 | CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, |
13 | 14 | CONCENTRATION_PARTS_PER_BILLION, |
@@ -107,6 +108,12 @@ class SensorDeviceClass(StrEnum): |
107 | 108 | """ |
108 | 109 |
|
109 | 110 | # Numerical device classes, these should be aligned with NumberDeviceClass |
| 111 | + ABSOLUTE_HUMIDITY = "absolute_humidity" |
| 112 | + """Absolute humidity. |
| 113 | +
|
| 114 | + Unit of measurement: `g/m³`, `mg/m³` |
| 115 | + """ |
| 116 | + |
110 | 117 | APPARENT_POWER = "apparent_power" |
111 | 118 | """Apparent power. |
112 | 119 |
|
@@ -521,6 +528,7 @@ class SensorStateClass(StrEnum): |
521 | 528 | STATE_CLASSES: Final[list[str]] = [cls.value for cls in SensorStateClass] |
522 | 529 |
|
523 | 530 | UNIT_CONVERTERS: dict[SensorDeviceClass | str | None, type[BaseUnitConverter]] = { |
| 531 | + SensorDeviceClass.ABSOLUTE_HUMIDITY: MassVolumeConcentrationConverter, |
524 | 532 | SensorDeviceClass.AREA: AreaConverter, |
525 | 533 | SensorDeviceClass.ATMOSPHERIC_PRESSURE: PressureConverter, |
526 | 534 | SensorDeviceClass.BLOOD_GLUCOSE_CONCENTRATION: BloodGlucoseConcentrationConverter, |
@@ -554,6 +562,10 @@ class SensorStateClass(StrEnum): |
554 | 562 | } |
555 | 563 |
|
556 | 564 | DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = { |
| 565 | + SensorDeviceClass.ABSOLUTE_HUMIDITY: { |
| 566 | + CONCENTRATION_GRAMS_PER_CUBIC_METER, |
| 567 | + CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, |
| 568 | + }, |
557 | 569 | SensorDeviceClass.APPARENT_POWER: set(UnitOfApparentPower), |
558 | 570 | SensorDeviceClass.AQI: {None}, |
559 | 571 | SensorDeviceClass.AREA: set(UnitOfArea), |
@@ -651,6 +663,7 @@ class SensorStateClass(StrEnum): |
651 | 663 | # have 0 decimals, that one should be used and not mW, even though mW also should have |
652 | 664 | # 0 decimals. Otherwise the smaller units will have more decimals than expected. |
653 | 665 | UNITS_PRECISION = { |
| 666 | + SensorDeviceClass.ABSOLUTE_HUMIDITY: (CONCENTRATION_GRAMS_PER_CUBIC_METER, 1), |
654 | 667 | SensorDeviceClass.APPARENT_POWER: (UnitOfApparentPower.VOLT_AMPERE, 0), |
655 | 668 | SensorDeviceClass.AREA: (UnitOfArea.SQUARE_CENTIMETERS, 0), |
656 | 669 | SensorDeviceClass.ATMOSPHERIC_PRESSURE: (UnitOfPressure.PA, 0), |
@@ -691,6 +704,7 @@ class SensorStateClass(StrEnum): |
691 | 704 | } |
692 | 705 |
|
693 | 706 | DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass]] = { |
| 707 | + SensorDeviceClass.ABSOLUTE_HUMIDITY: {SensorStateClass.MEASUREMENT}, |
694 | 708 | SensorDeviceClass.APPARENT_POWER: {SensorStateClass.MEASUREMENT}, |
695 | 709 | SensorDeviceClass.AQI: {SensorStateClass.MEASUREMENT}, |
696 | 710 | SensorDeviceClass.AREA: set(SensorStateClass), |
|
0 commit comments