Skip to content

Commit

Permalink
feat: add sensors for scales (#56)
Browse files Browse the repository at this point in the history
Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
Ernst79 and bdraco authored Jul 17, 2023
1 parent c769dee commit 8c3160e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/sensor_state_data/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ class SensorLibrary:
device_class=SensorDeviceClass.GYROSCOPE,
native_unit_of_measurement=Units.GYROSCOPE_DEGREES_PER_SECOND,
)
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 All @@ -72,6 +68,10 @@ class SensorLibrary:
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=Units.PERCENTAGE,
)
IMPEDANCE__OHM = BaseSensorDescription(
device_class=SensorDeviceClass.IMPEDANCE,
native_unit_of_measurement=Units.OHM,
)
KEG_SIZE__VOLUME_LITERS = BaseSensorDescription(
device_class=SensorDeviceClass.KEG_SIZE,
native_unit_of_measurement=Units.VOLUME_LITERS,
Expand All @@ -96,6 +96,22 @@ class SensorLibrary:
device_class=SensorDeviceClass.MOISTURE,
native_unit_of_measurement=Units.PERCENTAGE,
)
MASS_NON_STABILIZED__MASS_KILOGRAMS = BaseSensorDescription(
device_class=SensorDeviceClass.MASS_NON_STABILIZED,
native_unit_of_measurement=Units.MASS_KILOGRAMS,
)
MASS_NON_STABILIZED__MASS_POUNDS = BaseSensorDescription(
device_class=SensorDeviceClass.MASS_NON_STABILIZED,
native_unit_of_measurement=Units.MASS_POUNDS,
)
MASS_STABILIZED__MASS_KILOGRAMS = BaseSensorDescription(
device_class=SensorDeviceClass.MASS_STABILIZED,
native_unit_of_measurement=Units.MASS_KILOGRAMS,
)
MASS_STABILIZED__MASS_POUNDS = BaseSensorDescription(
device_class=SensorDeviceClass.MASS_STABILIZED,
native_unit_of_measurement=Units.MASS_POUNDS,
)
PACKET_ID__NONE = BaseSensorDescription(
device_class=SensorDeviceClass.PACKET_ID,
native_unit_of_measurement=None,
Expand Down Expand Up @@ -170,6 +186,10 @@ class SensorLibrary:
device_class=SensorDeviceClass.VOLUME_DISPENSED,
native_unit_of_measurement=Units.VOLUME_LITERS,
)
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,
)
VOLUME_START__VOLUME_LITERS = BaseSensorDescription(
device_class=SensorDeviceClass.VOLUME_START,
native_unit_of_measurement=Units.VOLUME_LITERS,
Expand Down
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 @@ -69,6 +69,9 @@ class SensorDeviceClass(BaseDeviceClass):
# current light level (lx/lm)
ILLUMINANCE = "illuminance"

# impedance (Ohm)
IMPEDANCE = "impedance"

# keg size (L)
KEG_SIZE = "keg_size"

Expand All @@ -81,6 +84,12 @@ class SensorDeviceClass(BaseDeviceClass):
# mass (g, kg, lbs)
MASS = "mass"

# mass non-stabilized (kg/lbs)
MASS_NON_STABILIZED = "mass_non_stabilized"

# mass stabilized (kg/lbs)
MASS_STABILIZED = "mass_stabilized"

# Amount of money (currency)
MONETARY = "monetary"

Expand Down
3 changes: 3 additions & 0 deletions src/sensor_state_data/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class Units(StrEnum):
MASS_OUNCES: Final = "oz"
MASS_POUNDS: Final = "lb"

# Impedance units
OHM: Final = "ohm"

# Conductivity units
CONDUCTIVITY: Final = "µS/cm"

Expand Down

0 comments on commit 8c3160e

Please sign in to comment.