Skip to content

Commit

Permalink
feat(sensor): add new device classes and units of measurement for are…
Browse files Browse the repository at this point in the history
…a, blood glucose concentration, conductivity, potential hydrogen, and volume flow rate

Closes #1710
  • Loading branch information
zachowj committed Dec 31, 2024
1 parent 462f6dd commit 0e621aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/nodes/entity-config/editor/data/common.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export enum DeviceClass {
ApparentPower = 'apparent_power',
Aqi = 'aqi',
Area = 'area',
AtmosphericPressure = 'atmospheric_pressure',
Battery = 'battery',
BloodGlucoseConcentration = 'blood_glucose_concentration',
CarbonDioxide = 'carbon_dioxide',
CarbonMonoxide = 'carbon_monoxide',
Conductivity = 'conductivity',
Current = 'current',
DataRate = 'data_rate',
DataSize = 'data_size',
Expand All @@ -28,6 +31,7 @@ export enum DeviceClass {
Pm1 = 'pm1',
Pm10 = 'pm10',
Pm25 = 'pm25',
PotentialHydrogen = 'potential_hydrogen',
Power = 'power',
PowerFactor = 'power_factor',
Precipitation = 'precipitation',
Expand All @@ -41,8 +45,10 @@ export enum DeviceClass {
Temperature = 'temperature',
Timestamp = 'timestamp',
VolatileOrganicCompounds = 'volatile_organic_compounds',
VolatileOrganicCompoundsParts = 'volatile_organic_compounds_parts',
Voltage = 'voltage',
Volume = 'volume',
VolumeFlowRate = 'volume_flow_rate',
VolumeStorage = 'volume_storage',
Water = 'water',
Weight = 'weight',
Expand Down
7 changes: 7 additions & 0 deletions src/nodes/entity-config/editor/data/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"device_class_options": {
"apparent_power": "apparent power",
"aqi": "aqi",
"area": "area",
"atmospheric_pressure": "atmospheric pressure",
"battery": "battery",
"battery_charging": "battery charging",
"blood_glucose_concentration": "blood glucose concentration",
"carbon_dioxide": "carbon dioxide",
"carbon_monoxide": "carbon monoxide",
"co": "co",
"conductivity": "conductivity",
"cold": "cold",
"connectivity": "connectivity",
"current": "current",
Expand All @@ -23,6 +26,7 @@
"duration": "duration",
"energy": "energy",
"energy_storage": "energy storage",
"enum": "enum",
"frequency": "frequency",
"garage_door": "garage door",
"gas": "gas",
Expand All @@ -47,6 +51,7 @@
"pm1": "pm1",
"pm10": "pm10",
"pm25": "pm25",
"potential_hydrogen": "potential hydrogen",
"power": "power",
"power_factor": "power factor",
"precipitation": "precipitation",
Expand All @@ -71,8 +76,10 @@
"update": "update",
"vibration": "vibration",
"volatile_organic_compounds": "volatile organic compounds",
"volatile_organic_compounds_parts": "volatile organic compounds parts",
"voltage": "voltage",
"volume": "volume",
"volume_flow_rate": "volume flow rate",
"volume_storage": "volume storage",
"water": "water",
"weight": "weight",
Expand Down
12 changes: 12 additions & 0 deletions src/nodes/entity-config/editor/data/sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { DeviceClass, monetaryList } from './common';
const sensorDeviceClasses = [
DeviceClass.ApparentPower,
DeviceClass.Aqi,
DeviceClass.Area,
DeviceClass.AtmosphericPressure,
DeviceClass.Battery,
DeviceClass.BloodGlucoseConcentration,
DeviceClass.CarbonDioxide,
DeviceClass.CarbonMonoxide,
DeviceClass.Conductivity,
DeviceClass.Current,
DeviceClass.DataRate,
DeviceClass.DataSize,
Expand All @@ -31,6 +34,7 @@ const sensorDeviceClasses = [
DeviceClass.Pm1,
DeviceClass.Pm10,
DeviceClass.Pm25,
DeviceClass.PotentialHydrogen,
DeviceClass.Power,
DeviceClass.PowerFactor,
DeviceClass.Precipitation,
Expand All @@ -44,8 +48,10 @@ const sensorDeviceClasses = [
DeviceClass.Temperature,
DeviceClass.Timestamp,
DeviceClass.VolatileOrganicCompounds,
DeviceClass.VolatileOrganicCompoundsParts,
DeviceClass.Voltage,
DeviceClass.Volume,
DeviceClass.VolumeFlowRate,
DeviceClass.VolumeStorage,
DeviceClass.Water,
DeviceClass.Weight,
Expand All @@ -58,6 +64,7 @@ export const sensorUnitOfMeasurement: Record<
> = {
apparent_power: ['VA'],
aqi: null,
area: ['m²', 'cm²', 'km²', 'mm²', 'in²', 'ft²', 'yd²', 'mi²', 'ac', 'ha'],
atmospheric_pressure: [
'cbar',
'bar',
Expand All @@ -69,8 +76,10 @@ export const sensorUnitOfMeasurement: Record<
'psi',
],
battery: ['%'],
blood_glucose_concentration: ['mg/dL', 'mmol/L'],
carbon_dioxide: ['ppm'],
carbon_monoxide: ['ppm'],
conductivity: ['S/cm', 'mS/cm', 'µS/cm'],
current: ['A'],
data_rate: [
'bit/s',
Expand Down Expand Up @@ -128,6 +137,7 @@ export const sensorUnitOfMeasurement: Record<
pm1: ['µg/m³'],
pm25: ['µg/m³'],
pm10: ['µg/m³'],
potential_hydrogen: null,
power: ['W', 'kW'],
power_factor: ['%'],
precipitation: ['mm', 'in', 'cm'],
Expand All @@ -141,8 +151,10 @@ export const sensorUnitOfMeasurement: Record<
temperature: ['°C', '°F'],
timestamp: null,
volatile_organic_compounds: ['µg/m³'],
volatile_organic_compounds_parts: ['ppm', 'ppb'],
voltage: ['V'],
volume: ['fl. oz.', 'ft³', 'gal', 'L', 'mL', 'm³'],
volume_flow_rate: ['m³/h', 'ft³/min', 'L/min', 'gal/min', 'mL/s'],
volume_storage: ['L', 'mL', 'gal', 'fl. oz.', 'm³', 'ft³', 'CCF'],
water: ['L', 'gal', 'm³', 'ft³'],
weight: ['g', 'kg', 'lb', 'mg', 'oz', 'µg'],
Expand Down

0 comments on commit 0e621aa

Please sign in to comment.