Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/sensor_state_data/sensor/device_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class SensorDeviceClass(BaseDeviceClass):
# % of battery that is left
BATTERY = "battery"

# blood glucose concentration (mg/dL, mmol/L)
BLOOD_GLUCOSE_CONCENTRATION = "blood_glucose_concentration"

# ppm (parts per million) Carbon Monoxide gas concentration
CO = "carbon_monoxide"

Expand Down Expand Up @@ -144,6 +147,9 @@ class SensorDeviceClass(BaseDeviceClass):
# signal strength (dB/dBm)
SIGNAL_STRENGTH = "signal_strength"

# sound pressure (dB, dBA)
SOUND_PRESSURE = "sound_pressure"

# specific gravity
SPECIFIC_GRAVITY = "specific_gravity"

Expand All @@ -168,6 +174,9 @@ class SensorDeviceClass(BaseDeviceClass):
# Amount of VOC (µg/m³)
VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"

# Ratio of VOC (ppm, ppb)
VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts"

# voltage (V)
VOLTAGE = "voltage"

Expand Down
24 changes: 24 additions & 0 deletions tests/test_sensor_device_class_health_air.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Pin the HA interop string values for recently added sensor device classes.

These string values are the contract with Home Assistant. They must match HA's
``SensorDeviceClass`` exactly, so drift is caught here rather than downstream.
"""

from sensor_state_data import SensorDeviceClass


def test_blood_glucose_concentration_value():
assert (
SensorDeviceClass.BLOOD_GLUCOSE_CONCENTRATION == "blood_glucose_concentration"
)


def test_sound_pressure_value():
assert SensorDeviceClass.SOUND_PRESSURE == "sound_pressure"


def test_volatile_organic_compounds_parts_value():
assert (
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS
== "volatile_organic_compounds_parts"
)
Loading