Add device class moisture (#77666)

pull/77673/head
Ernst Klamer 2022-09-01 17:47:47 +02:00 committed by GitHub
parent cd2045b66d
commit db4391adff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 2 deletions

View File

@ -119,6 +119,9 @@ class SensorDeviceClass(StrEnum):
# current light level (lx/lm)
ILLUMINANCE = "illuminance"
# moisture (%)
MOISTURE = "moisture"
# Amount of money (currency)
MONETARY = "monetary"

View File

@ -43,6 +43,7 @@ CONF_IS_FREQUENCY = "is_frequency"
CONF_IS_HUMIDITY = "is_humidity"
CONF_IS_GAS = "is_gas"
CONF_IS_ILLUMINANCE = "is_illuminance"
CONF_IS_MOISTURE = "is_moisture"
CONF_IS_NITROGEN_DIOXIDE = "is_nitrogen_dioxide"
CONF_IS_NITROGEN_MONOXIDE = "is_nitrogen_monoxide"
CONF_IS_NITROUS_OXIDE = "is_nitrous_oxide"
@ -72,6 +73,7 @@ ENTITY_CONDITIONS = {
SensorDeviceClass.GAS: [{CONF_TYPE: CONF_IS_GAS}],
SensorDeviceClass.HUMIDITY: [{CONF_TYPE: CONF_IS_HUMIDITY}],
SensorDeviceClass.ILLUMINANCE: [{CONF_TYPE: CONF_IS_ILLUMINANCE}],
SensorDeviceClass.MOISTURE: [{CONF_TYPE: CONF_IS_MOISTURE}],
SensorDeviceClass.NITROGEN_DIOXIDE: [{CONF_TYPE: CONF_IS_NITROGEN_DIOXIDE}],
SensorDeviceClass.NITROGEN_MONOXIDE: [{CONF_TYPE: CONF_IS_NITROGEN_MONOXIDE}],
SensorDeviceClass.NITROUS_OXIDE: [{CONF_TYPE: CONF_IS_NITROUS_OXIDE}],
@ -110,6 +112,7 @@ CONDITION_SCHEMA = vol.All(
CONF_IS_HUMIDITY,
CONF_IS_ILLUMINANCE,
CONF_IS_OZONE,
CONF_IS_MOISTURE,
CONF_IS_NITROGEN_DIOXIDE,
CONF_IS_NITROGEN_MONOXIDE,
CONF_IS_NITROUS_OXIDE,

View File

@ -42,6 +42,7 @@ CONF_FREQUENCY = "frequency"
CONF_GAS = "gas"
CONF_HUMIDITY = "humidity"
CONF_ILLUMINANCE = "illuminance"
CONF_MOISTURE = "moisture"
CONF_NITROGEN_DIOXIDE = "nitrogen_dioxide"
CONF_NITROGEN_MONOXIDE = "nitrogen_monoxide"
CONF_NITROUS_OXIDE = "nitrous_oxide"
@ -71,6 +72,7 @@ ENTITY_TRIGGERS = {
SensorDeviceClass.GAS: [{CONF_TYPE: CONF_GAS}],
SensorDeviceClass.HUMIDITY: [{CONF_TYPE: CONF_HUMIDITY}],
SensorDeviceClass.ILLUMINANCE: [{CONF_TYPE: CONF_ILLUMINANCE}],
SensorDeviceClass.MOISTURE: [{CONF_TYPE: CONF_MOISTURE}],
SensorDeviceClass.NITROGEN_DIOXIDE: [{CONF_TYPE: CONF_NITROGEN_DIOXIDE}],
SensorDeviceClass.NITROGEN_MONOXIDE: [{CONF_TYPE: CONF_NITROGEN_MONOXIDE}],
SensorDeviceClass.NITROUS_OXIDE: [{CONF_TYPE: CONF_NITROUS_OXIDE}],
@ -109,6 +111,7 @@ TRIGGER_SCHEMA = vol.All(
CONF_GAS,
CONF_HUMIDITY,
CONF_ILLUMINANCE,
CONF_MOISTURE,
CONF_NITROGEN_DIOXIDE,
CONF_NITROGEN_MONOXIDE,
CONF_NITROUS_OXIDE,

View File

@ -9,6 +9,7 @@
"is_gas": "Current {entity_name} gas",
"is_humidity": "Current {entity_name} humidity",
"is_illuminance": "Current {entity_name} illuminance",
"is_moisture": "Current {entity_name} moisture",
"is_nitrogen_dioxide": "Current {entity_name} nitrogen dioxide concentration level",
"is_nitrogen_monoxide": "Current {entity_name} nitrogen monoxide concentration level",
"is_nitrous_oxide": "Current {entity_name} nitrous oxide concentration level",
@ -38,6 +39,7 @@
"gas": "{entity_name} gas changes",
"humidity": "{entity_name} humidity changes",
"illuminance": "{entity_name} illuminance changes",
"moisture": "{entity_name} moisture changes",
"nitrogen_dioxide": "{entity_name} nitrogen dioxide concentration changes",
"nitrogen_monoxide": "{entity_name} nitrogen monoxide concentration changes",
"nitrous_oxide": "{entity_name} nitrous oxide concentration changes",

View File

@ -85,7 +85,7 @@ async def test_get_conditions(hass, device_reg, entity_reg, enable_custom_integr
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert len(conditions) == 26
assert len(conditions) == 27
assert_lists_same(conditions, expected_conditions)

View File

@ -89,7 +89,7 @@ async def test_get_triggers(hass, device_reg, entity_reg, enable_custom_integrat
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert len(triggers) == 26
assert len(triggers) == 27
assert_lists_same(triggers, expected_triggers)

View File

@ -32,6 +32,7 @@ UNITS_OF_MEASUREMENT = {
SensorDeviceClass.CO2: CONCENTRATION_PARTS_PER_MILLION, # ppm of CO2 concentration
SensorDeviceClass.HUMIDITY: PERCENTAGE, # % of humidity in the air
SensorDeviceClass.ILLUMINANCE: "lm", # current light level (lx/lm)
SensorDeviceClass.MOISTURE: PERCENTAGE, # % of water in a substance
SensorDeviceClass.NITROGEN_DIOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen dioxide
SensorDeviceClass.NITROGEN_MONOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen monoxide
SensorDeviceClass.NITROUS_OXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen oxide