diff --git a/homeassistant/components/onewire/const.py b/homeassistant/components/onewire/const.py index 23a686767b0..83ffa12706c 100644 --- a/homeassistant/components/onewire/const.py +++ b/homeassistant/components/onewire/const.py @@ -13,6 +13,8 @@ DEFAULT_SYSBUS_MOUNT_DIR = "/sys/bus/w1/devices/" DOMAIN = "onewire" +PRESSURE_CBAR = "cbar" + SUPPORTED_PLATFORMS = [ SENSOR_DOMAIN, ] diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index d6e8ef50f46..3b7eeb50c29 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -14,6 +14,7 @@ from homeassistant.const import ( ELECTRICAL_CURRENT_AMPERE, LIGHT_LUX, PERCENTAGE, + PRESSURE_MBAR, TEMP_CELSIUS, VOLT, ) @@ -28,6 +29,7 @@ from .const import ( CONF_TYPE_SYSBUS, DEFAULT_OWSERVER_PORT, DEFAULT_SYSBUS_MOUNT_DIR, + PRESSURE_CBAR, ) _LOGGER = logging.getLogger(__name__) @@ -86,16 +88,16 @@ SENSOR_TYPES = { "humidity_hih5030": ["humidity", PERCENTAGE], "humidity_htm1735": ["humidity", PERCENTAGE], "humidity_raw": ["humidity", PERCENTAGE], - "pressure": ["pressure", "mb"], + "pressure": ["pressure", PRESSURE_MBAR], "illuminance": ["illuminance", LIGHT_LUX], "wetness_0": ["wetness", PERCENTAGE], "wetness_1": ["wetness", PERCENTAGE], "wetness_2": ["wetness", PERCENTAGE], "wetness_3": ["wetness", PERCENTAGE], - "moisture_0": ["moisture", "cb"], - "moisture_1": ["moisture", "cb"], - "moisture_2": ["moisture", "cb"], - "moisture_3": ["moisture", "cb"], + "moisture_0": ["moisture", PRESSURE_CBAR], + "moisture_1": ["moisture", PRESSURE_CBAR], + "moisture_2": ["moisture", PRESSURE_CBAR], + "moisture_3": ["moisture", PRESSURE_CBAR], "counter_a": ["counter", "count"], "counter_b": ["counter", "count"], "HobbyBoard": ["none", "none"], diff --git a/tests/components/onewire/test_entity_owserver.py b/tests/components/onewire/test_entity_owserver.py index 290c744ab94..95b0137f7eb 100644 --- a/tests/components/onewire/test_entity_owserver.py +++ b/tests/components/onewire/test_entity_owserver.py @@ -4,7 +4,11 @@ from unittest.mock import patch from pyownet.protocol import Error as ProtocolError import pytest -from homeassistant.components.onewire.const import DEFAULT_OWSERVER_PORT, DOMAIN +from homeassistant.components.onewire.const import ( + DEFAULT_OWSERVER_PORT, + DOMAIN, + PRESSURE_CBAR, +) from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.const import PERCENTAGE, TEMP_CELSIUS from homeassistant.setup import async_setup_component @@ -153,14 +157,14 @@ MOCK_DEVICE_SENSORS = { "unique_id": "/EF.111111111112/moisture/sensor.2", "injected_value": b" 43.123", "result": "43.1", - "unit": "cb", + "unit": PRESSURE_CBAR, }, { "entity_id": "sensor.ef_111111111112_moisture_3", "unique_id": "/EF.111111111112/moisture/sensor.3", "injected_value": b" 44.123", "result": "44.1", - "unit": "cb", + "unit": PRESSURE_CBAR, }, ], },