Add and use more unit constants (#32122)
* Add and use speed constants * Add and use meter based volume and area constants * Add and use more mass unit constants * Add and use concentration unit constants * Add and use watts per square meter constant * Use more time constants * Use more data constants
This commit is contained in:
1 parent
c98f50115d
commit
496bd3dddf
44 files changed
+422
-177
No files matched your search
@@ -16,6 +16,9 @@ from homeassistant.components.awair.sensor import (
|
||||
)
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONCENTRATION_PARTS_PER_BILLION,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
STATE_UNAVAILABLE,
|
||||
@@ -183,7 +186,7 @@ async def test_awair_co2(hass):
|
||||
sensor = hass.states.get("sensor.awair_co2")
|
||||
assert sensor.state == "612"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_CARBON_DIOXIDE
|
||||
assert sensor.attributes["unit_of_measurement"] == "ppm"
|
||||
assert sensor.attributes["unit_of_measurement"] == CONCENTRATION_PARTS_PER_MILLION
|
||||
|
||||
|
||||
async def test_awair_voc(hass):
|
||||
@@ -193,7 +196,7 @@ async def test_awair_voc(hass):
|
||||
sensor = hass.states.get("sensor.awair_voc")
|
||||
assert sensor.state == "1012"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS
|
||||
assert sensor.attributes["unit_of_measurement"] == "ppb"
|
||||
assert sensor.attributes["unit_of_measurement"] == CONCENTRATION_PARTS_PER_BILLION
|
||||
|
||||
|
||||
async def test_awair_dust(hass):
|
||||
@@ -205,7 +208,10 @@ async def test_awair_dust(hass):
|
||||
sensor = hass.states.get("sensor.awair_pm2_5")
|
||||
assert sensor.state == "6.2"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_PM2_5
|
||||
assert sensor.attributes["unit_of_measurement"] == "µg/m3"
|
||||
assert (
|
||||
sensor.attributes["unit_of_measurement"]
|
||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||
)
|
||||
|
||||
|
||||
async def test_awair_unsupported_sensors(hass):
|
||||
|
||||
Reference in new issue
Block a user