Skip to content

Commit

Permalink
Add sensor device class volatile_organic_compounds_parts (#92973)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed May 12, 2023
1 parent 7546e8e commit 5a7c3aa
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions homeassistant/components/number/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.backports.enum import StrEnum
from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
Expand Down Expand Up @@ -309,6 +310,12 @@ class NumberDeviceClass(StrEnum):
Unit of measurement: `µg/m³`
"""

VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts"
"""Ratio of VOC.
Unit of measurement: `ppm`, `ppb`
"""

VOLTAGE = "voltage"
"""Voltage.
Expand Down Expand Up @@ -421,6 +428,10 @@ class NumberMode(StrEnum):
NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
},
NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: {
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
},
NumberDeviceClass.VOLTAGE: set(UnitOfElectricPotential),
NumberDeviceClass.VOLUME: set(UnitOfVolume),
NumberDeviceClass.VOLUME_STORAGE: set(UnitOfVolume),
Expand Down
12 changes: 12 additions & 0 deletions homeassistant/components/sensor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.backports.enum import StrEnum
from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
Expand Down Expand Up @@ -347,6 +348,12 @@ class SensorDeviceClass(StrEnum):
Unit of measurement: `µg/m³`
"""

VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts"
"""Ratio of VOC.
Unit of measurement: `ppm`, `ppb`
"""

VOLTAGE = "voltage"
"""Voltage.
Expand Down Expand Up @@ -521,6 +528,10 @@ class SensorStateClass(StrEnum):
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
},
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: {
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
},
SensorDeviceClass.VOLTAGE: set(UnitOfElectricPotential),
SensorDeviceClass.VOLUME: set(UnitOfVolume),
SensorDeviceClass.WATER: {
Expand Down Expand Up @@ -580,6 +591,7 @@ class SensorStateClass(StrEnum):
SensorDeviceClass.TEMPERATURE: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.TIMESTAMP: set(),
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.VOLTAGE: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.VOLUME: {
SensorStateClass.TOTAL,
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/sensor/device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
CONF_IS_TEMPERATURE = "is_temperature"
CONF_IS_VALUE = "is_value"
CONF_IS_VOLATILE_ORGANIC_COMPOUNDS = "is_volatile_organic_compounds"
CONF_IS_VOLATILE_ORGANIC_COMPOUNDS_PARTS = "is_volatile_organic_compounds_parts"
CONF_IS_VOLTAGE = "is_voltage"
CONF_IS_VOLUME = "is_volume"
CONF_IS_WATER = "is_water"
Expand Down Expand Up @@ -120,6 +121,9 @@
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: [
{CONF_TYPE: CONF_IS_VOLATILE_ORGANIC_COMPOUNDS}
],
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: [
{CONF_TYPE: CONF_IS_VOLATILE_ORGANIC_COMPOUNDS_PARTS}
],
SensorDeviceClass.VOLTAGE: [{CONF_TYPE: CONF_IS_VOLTAGE}],
SensorDeviceClass.VOLUME: [{CONF_TYPE: CONF_IS_VOLUME}],
SensorDeviceClass.VOLUME_STORAGE: [{CONF_TYPE: CONF_IS_VOLUME}],
Expand Down Expand Up @@ -173,6 +177,7 @@
CONF_IS_SULPHUR_DIOXIDE,
CONF_IS_TEMPERATURE,
CONF_IS_VOLATILE_ORGANIC_COMPOUNDS,
CONF_IS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
CONF_IS_VOLTAGE,
CONF_IS_VOLUME,
CONF_IS_WATER,
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/sensor/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
CONF_TEMPERATURE = "temperature"
CONF_VALUE = "value"
CONF_VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
CONF_VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts"
CONF_VOLTAGE = "voltage"
CONF_VOLUME = "volume"
CONF_WATER = "water"
Expand Down Expand Up @@ -119,6 +120,9 @@
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: [
{CONF_TYPE: CONF_VOLATILE_ORGANIC_COMPOUNDS}
],
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: [
{CONF_TYPE: CONF_VOLATILE_ORGANIC_COMPOUNDS_PARTS}
],
SensorDeviceClass.VOLTAGE: [{CONF_TYPE: CONF_VOLTAGE}],
SensorDeviceClass.VOLUME: [{CONF_TYPE: CONF_VOLUME}],
SensorDeviceClass.VOLUME_STORAGE: [{CONF_TYPE: CONF_VOLUME}],
Expand Down Expand Up @@ -173,6 +177,7 @@
CONF_SULPHUR_DIOXIDE,
CONF_TEMPERATURE,
CONF_VOLATILE_ORGANIC_COMPOUNDS,
CONF_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
CONF_VOLTAGE,
CONF_VOLUME,
CONF_WATER,
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/sensor/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"is_temperature": "Current {entity_name} temperature",
"is_value": "Current {entity_name} value",
"is_volatile_organic_compounds": "Current {entity_name} volatile organic compounds concentration level",
"is_volatile_organic_compounds_parts": "[%key:component::sensor::device_automation::condition_type::is_volatile_organic_compounds%]",
"is_voltage": "Current {entity_name} voltage",
"is_volume": "Current {entity_name} volume",
"is_water": "Current {entity_name} water",
Expand Down Expand Up @@ -87,6 +88,7 @@
"temperature": "{entity_name} temperature changes",
"value": "{entity_name} value changes",
"volatile_organic_compounds": "{entity_name} volatile organic compounds concentration changes",
"volatile_organic_compounds_parts": "[%key:component::sensor::device_automation::trigger_type::volatile_organic_compounds%]",
"voltage": "{entity_name} voltage changes",
"volume": "{entity_name} volume changes",
"water": "{entity_name} water changes",
Expand Down Expand Up @@ -244,6 +246,9 @@
"volatile_organic_compounds": {
"name": "VOCs"
},
"volatile_organic_compounds_parts": {
"name": "[%key:component::sensor::entity_component::volatile_organic_compounds::name%]"
},
"voltage": {
"name": "Voltage"
},
Expand Down
1 change: 1 addition & 0 deletions tests/components/sensor/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,7 @@ async def test_non_numeric_device_class_with_unit_of_measurement(
SensorDeviceClass.SULPHUR_DIOXIDE,
SensorDeviceClass.TEMPERATURE,
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS,
SensorDeviceClass.VOLTAGE,
SensorDeviceClass.VOLUME,
SensorDeviceClass.WATER,
Expand Down

0 comments on commit 5a7c3aa

Please sign in to comment.