Skip to content

Commit

Permalink
feat: add volume and packet_id sensor types (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 authored Dec 17, 2022
1 parent a5b4efe commit cda847e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sensor_state_data/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class SensorLibrary:
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=Units.ENERGY_KILO_WATT_HOUR,
)
VOLUME_FLOW_RATE__VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR = BaseSensorDescription(
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
native_unit_of_measurement=Units.VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
)
FORMALDEHYDE__CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER = BaseSensorDescription(
device_class=SensorDeviceClass.FORMALDEHYDE,
native_unit_of_measurement=Units.CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
Expand Down Expand Up @@ -84,6 +88,10 @@ class SensorLibrary:
device_class=SensorDeviceClass.MOISTURE,
native_unit_of_measurement=Units.PERCENTAGE,
)
PACKET_ID__NONE = BaseSensorDescription(
device_class=SensorDeviceClass.PACKET_ID,
native_unit_of_measurement=None,
)
PM1__CONCENTRATION_MICROGRAMS_PER_CUBIC_METER = BaseSensorDescription(
device_class=SensorDeviceClass.PM1,
native_unit_of_measurement=Units.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
Expand Down Expand Up @@ -150,3 +158,11 @@ class SensorLibrary:
device_class=SensorDeviceClass.VOLUME_START,
native_unit_of_measurement=Units.VOLUME_LITERS,
)
VOLUME__VOLUME_LITERS = BaseSensorDescription(
device_class=SensorDeviceClass.VOLUME,
native_unit_of_measurement=Units.VOLUME_LITERS,
)
VOLUME__VOLUME_MILLILITERS = BaseSensorDescription(
device_class=SensorDeviceClass.VOLUME,
native_unit_of_measurement=Units.VOLUME_MILLILITERS,
)
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 @@ -45,6 +45,9 @@ class SensorDeviceClass(BaseDeviceClass):
# energy (Wh, kWh, MWh)
ENERGY = "energy"

# Volume flow rate (m3 per hour)
VOLUME_FLOW_RATE = "volume_flow_rate"

# formaldehyde (µg/m³)
FORMALDEHYDE = "formaldehyde"

Expand Down Expand Up @@ -87,6 +90,9 @@ class SensorDeviceClass(BaseDeviceClass):
# Amount of O3 (µg/m³)
OZONE = "ozone"

# Packet id (no unit)
PACKET_ID = "packet_id"

# Particulate matter <= 0.1 μm (µg/m³)
PM1 = "pm1"

Expand Down Expand Up @@ -150,6 +156,9 @@ class SensorDeviceClass(BaseDeviceClass):
# voltage (V)
VOLTAGE = "voltage"

# Volume (ml, L)
VOLUME = "volume"

# Volume dispensed (L)
VOLUME_DISPENSED = "volume_dispensed"

Expand Down

0 comments on commit cda847e

Please sign in to comment.