From 70ce9bb7bc15b1a66bb1d21598efd0bb8b102522 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sat, 29 Sep 2018 22:01:04 +0200 Subject: [PATCH] Add pressure sensor device class (#16965) * Add pressure sensor device class * Undo github desktop line exclude --- homeassistant/components/sensor/__init__.py | 3 ++- homeassistant/components/sensor/xiaomi_aqara.py | 4 ++-- homeassistant/const.py | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index 948f844cfd4..be599cc295a 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -14,7 +14,7 @@ from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_TEMPERATURE) + DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_PRESSURE) _LOGGER = logging.getLogger(__name__) @@ -28,6 +28,7 @@ DEVICE_CLASSES = [ DEVICE_CLASS_HUMIDITY, # % of humidity in the air DEVICE_CLASS_ILLUMINANCE, # current light level (lx/lm) DEVICE_CLASS_TEMPERATURE, # temperature (C/F) + DEVICE_CLASS_PRESSURE, # pressure (hPa/mbar) ] DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.In(DEVICE_CLASSES)) diff --git a/homeassistant/components/sensor/xiaomi_aqara.py b/homeassistant/components/sensor/xiaomi_aqara.py index 8a3a11db051..31366fe0097 100644 --- a/homeassistant/components/sensor/xiaomi_aqara.py +++ b/homeassistant/components/sensor/xiaomi_aqara.py @@ -5,7 +5,7 @@ from homeassistant.components.xiaomi_aqara import (PY_XIAOMI_GATEWAY, XiaomiDevice) from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE, - TEMP_CELSIUS) + TEMP_CELSIUS, DEVICE_CLASS_PRESSURE) _LOGGER = logging.getLogger(__name__) @@ -14,7 +14,7 @@ SENSOR_TYPES = { 'humidity': ['%', None, DEVICE_CLASS_HUMIDITY], 'illumination': ['lm', None, DEVICE_CLASS_ILLUMINANCE], 'lux': ['lx', None, DEVICE_CLASS_ILLUMINANCE], - 'pressure': ['hPa', 'mdi:gauge', None] + 'pressure': ['hPa', None, DEVICE_CLASS_PRESSURE] } diff --git a/homeassistant/const.py b/homeassistant/const.py index 1d3adf7ee45..93ab0deeba2 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -172,6 +172,7 @@ DEVICE_CLASS_BATTERY = 'battery' DEVICE_CLASS_HUMIDITY = 'humidity' DEVICE_CLASS_ILLUMINANCE = 'illuminance' DEVICE_CLASS_TEMPERATURE = 'temperature' +DEVICE_CLASS_PRESSURE = 'pressure' # #### STATES #### STATE_ON = 'on'