core/homeassistant/components/onewire/const.py

64 lines
2.3 KiB
Python
Raw Normal View History

"""Constants for 1-Wire component."""
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import (
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
ELECTRICAL_CURRENT_AMPERE,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_MBAR,
TEMP_CELSIUS,
VOLT,
)
CONF_MOUNT_DIR = "mount_dir"
CONF_NAMES = "names"
CONF_TYPE_OWFS = "OWFS"
CONF_TYPE_OWSERVER = "OWServer"
CONF_TYPE_SYSBUS = "SysBus"
Add config flow for One wire (#39321) * Add support for config_flow Add support for switches Add support for binary sensors * Add config flow strings * Update .coveragerc * black-formatting * fixes for isort and flake * fixes for pylint * fixes for isort * fixes for isort * fixes for config_flow * Add devices to Device Registry * Updated comments * fixes for flake8 * Updated comments * Updated comments * Implement async_unload_entry * remove binary_sensor and switch implementation (will move to new PR) * Update .coveragerc Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update .coveragerc * Review config flow to store the configuration type * Add config_flow tests * Move CONF_NAMES to constants * Fix isort * Tweak to onewire logger * Tweak to onewire logger for sensor * Reset _LOGGER variable * Normalise header * Normalise header * Update to use references in config flow translations * Improve test coverage * fixes for isort * Update async_unload_entry * Update common strings * Update imports * Move connect attempt to executor * Update common strings * Remove OWFS from config_flow * Prevent duplicate config entries * Fix isort * Fix flake8 * Fix tests following removal of OWFS implementation * Fix flake8 * Adjust config from yaml to config-flow, and add ability to specify sysbus directory * Ajust unique_id for config entries * Fix test_config_flow * Fix invalid merge * Convert yaml to config_entry * Update sysbus tests * Tweaks to yaml import process, and add OWFS warning * Enable migration of OWFS platform config to config_entry * update the existing corresponding config entry on OWFS conversion * Remove CONFIG_SCHEMA * Move data_schema to constants * Remove log message * Remove duplicate warning * Update already_configured to use already_configured_device constant * Schedule get_entities on the executor * Update duplicate entry check for OWServer * Review TryCatch * Schedule os.path.isdir on the executor * rename owhost/owport * Update checks for empty * Fix incorrect patch * Move config_flow validation methods to new OneWireHub * Fix typo and pre-commit * Cleanup try/else * patch async_setup/async_setup_entry * cleanup implicit exit point * Fix invalid patch * cleanup implicit exit point * cleanup implicit exit point Co-authored-by: Chris Talkington <chris@talkingtontech.com>
2020-10-24 01:57:16 +00:00
DEFAULT_OWSERVER_HOST = "localhost"
DEFAULT_OWSERVER_PORT = 4304
DEFAULT_SYSBUS_MOUNT_DIR = "/sys/bus/w1/devices/"
DOMAIN = "onewire"
PRESSURE_CBAR = "cbar"
SENSOR_TYPES = {
# SensorType: [ Measured unit, Unit, DeviceClass ]
"temperature": ["temperature", TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE],
"humidity": ["humidity", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"humidity_hih3600": ["humidity", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"humidity_hih4000": ["humidity", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"humidity_hih5030": ["humidity", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"humidity_htm1735": ["humidity", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"humidity_raw": ["humidity", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"pressure": ["pressure", PRESSURE_MBAR, DEVICE_CLASS_PRESSURE],
"illuminance": ["illuminance", LIGHT_LUX, DEVICE_CLASS_ILLUMINANCE],
"wetness_0": ["wetness", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"wetness_1": ["wetness", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"wetness_2": ["wetness", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"wetness_3": ["wetness", PERCENTAGE, DEVICE_CLASS_HUMIDITY],
"moisture_0": ["moisture", PRESSURE_CBAR, DEVICE_CLASS_PRESSURE],
"moisture_1": ["moisture", PRESSURE_CBAR, DEVICE_CLASS_PRESSURE],
"moisture_2": ["moisture", PRESSURE_CBAR, DEVICE_CLASS_PRESSURE],
"moisture_3": ["moisture", PRESSURE_CBAR, DEVICE_CLASS_PRESSURE],
"counter_a": ["counter", "count", None],
"counter_b": ["counter", "count", None],
"HobbyBoard": ["none", "none", None],
"voltage": ["voltage", VOLT, DEVICE_CLASS_VOLTAGE],
"voltage_VAD": ["voltage", VOLT, DEVICE_CLASS_VOLTAGE],
"voltage_VDD": ["voltage", VOLT, DEVICE_CLASS_VOLTAGE],
"current": ["current", ELECTRICAL_CURRENT_AMPERE, DEVICE_CLASS_CURRENT],
}
SUPPORTED_PLATFORMS = [
SENSOR_DOMAIN,
]