Add PRESSURE_CBAR to onewire constants (#41826)

pull/41914/head
epenet 2020-10-15 19:57:15 +02:00 committed by GitHub
parent 3ffa050905
commit ba789105ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 8 deletions

View File

@ -13,6 +13,8 @@ DEFAULT_SYSBUS_MOUNT_DIR = "/sys/bus/w1/devices/"
DOMAIN = "onewire"
PRESSURE_CBAR = "cbar"
SUPPORTED_PLATFORMS = [
SENSOR_DOMAIN,
]

View File

@ -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"],

View File

@ -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,
},
],
},