Remove deprecated sensor_class config options (#8702)
parent
8ba9e8016b
commit
8ac63fd70c
|
@ -13,10 +13,9 @@ import voluptuous as vol
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
|
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_RESOURCE, CONF_PIN, CONF_NAME, CONF_SENSOR_CLASS, CONF_DEVICE_CLASS)
|
CONF_RESOURCE, CONF_PIN, CONF_NAME, CONF_DEVICE_CLASS)
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_RESOURCE): cv.url,
|
vol.Required(CONF_RESOURCE): cv.url,
|
||||||
vol.Optional(CONF_NAME): cv.string,
|
vol.Optional(CONF_NAME): cv.string,
|
||||||
vol.Required(CONF_PIN): cv.string,
|
vol.Required(CONF_PIN): cv.string,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -35,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the aREST binary sensor."""
|
"""Set up the aREST binary sensor."""
|
||||||
resource = config.get(CONF_RESOURCE)
|
resource = config.get(CONF_RESOURCE)
|
||||||
pin = config.get(CONF_PIN)
|
pin = config.get(CONF_PIN)
|
||||||
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
device_class = config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(resource, timeout=10).json()
|
response = requests.get(resource, timeout=10).json()
|
||||||
|
|
|
@ -14,9 +14,8 @@ from homeassistant.components.binary_sensor import (
|
||||||
from homeassistant.components.sensor.command_line import CommandSensorData
|
from homeassistant.components.sensor.command_line import CommandSensorData
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PAYLOAD_OFF, CONF_PAYLOAD_ON, CONF_NAME, CONF_VALUE_TEMPLATE,
|
CONF_PAYLOAD_OFF, CONF_PAYLOAD_ON, CONF_NAME, CONF_VALUE_TEMPLATE,
|
||||||
CONF_SENSOR_CLASS, CONF_COMMAND, CONF_DEVICE_CLASS)
|
CONF_COMMAND, CONF_DEVICE_CLASS)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
|
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
|
||||||
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
|
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
|
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
|
||||||
})
|
})
|
||||||
|
@ -44,7 +42,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
command = config.get(CONF_COMMAND)
|
command = config.get(CONF_COMMAND)
|
||||||
payload_off = config.get(CONF_PAYLOAD_OFF)
|
payload_off = config.get(CONF_PAYLOAD_OFF)
|
||||||
payload_on = config.get(CONF_PAYLOAD_ON)
|
payload_on = config.get(CONF_PAYLOAD_ON)
|
||||||
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
device_class = config.get(CONF_DEVICE_CLASS)
|
||||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||||
if value_template is not None:
|
if value_template is not None:
|
||||||
value_template.hass = hass
|
value_template.hass = hass
|
||||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.components.digital_ocean import (
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_NAME = 'Droplet'
|
DEFAULT_NAME = 'Droplet'
|
||||||
DEFAULT_SENSOR_CLASS = 'moving'
|
DEFAULT_DEVICE_CLASS = 'moving'
|
||||||
DEPENDENCIES = ['digital_ocean']
|
DEPENDENCIES = ['digital_ocean']
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
@ -69,7 +69,7 @@ class DigitalOceanBinarySensor(BinarySensorDevice):
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return DEFAULT_SENSOR_CLASS
|
return DEFAULT_DEVICE_CLASS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -12,9 +12,8 @@ from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
|
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
|
||||||
from homeassistant.components import enocean
|
from homeassistant.components import enocean
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, CONF_ID, CONF_SENSOR_CLASS, CONF_DEVICE_CLASS)
|
CONF_NAME, CONF_ID, CONF_DEVICE_CLASS)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -24,7 +23,6 @@ DEFAULT_NAME = 'EnOcean binary sensor'
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]),
|
vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]),
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -33,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the Binary Sensor platform for EnOcean."""
|
"""Set up the Binary Sensor platform for EnOcean."""
|
||||||
dev_id = config.get(CONF_ID)
|
dev_id = config.get(CONF_ID)
|
||||||
devname = config.get(CONF_NAME)
|
devname = config.get(CONF_NAME)
|
||||||
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
device_class = config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
add_devices([EnOceanBinarySensor(dev_id, devname, device_class)])
|
add_devices([EnOceanBinarySensor(dev_id, devname, device_class)])
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,9 @@ from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDevice, DEVICE_CLASSES_SCHEMA)
|
BinarySensorDevice, DEVICE_CLASSES_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_ON, CONF_PAYLOAD_OFF,
|
CONF_NAME, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_ON, CONF_PAYLOAD_OFF,
|
||||||
CONF_SENSOR_CLASS, CONF_DEVICE_CLASS)
|
CONF_DEVICE_CLASS)
|
||||||
from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS)
|
from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
|
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
|
||||||
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
|
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
async_add_devices([MqttBinarySensor(
|
async_add_devices([MqttBinarySensor(
|
||||||
config.get(CONF_NAME),
|
config.get(CONF_NAME),
|
||||||
config.get(CONF_STATE_TOPIC),
|
config.get(CONF_STATE_TOPIC),
|
||||||
get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS),
|
config.get(CONF_DEVICE_CLASS),
|
||||||
config.get(CONF_QOS),
|
config.get(CONF_QOS),
|
||||||
config.get(CONF_PAYLOAD_ON),
|
config.get(CONF_PAYLOAD_ON),
|
||||||
config.get(CONF_PAYLOAD_OFF),
|
config.get(CONF_PAYLOAD_OFF),
|
||||||
|
|
|
@ -28,7 +28,7 @@ CONF_PING_COUNT = 'count'
|
||||||
|
|
||||||
DEFAULT_NAME = 'Ping Binary sensor'
|
DEFAULT_NAME = 'Ping Binary sensor'
|
||||||
DEFAULT_PING_COUNT = 5
|
DEFAULT_PING_COUNT = 5
|
||||||
DEFAULT_SENSOR_CLASS = 'connectivity'
|
DEFAULT_DEVICE_CLASS = 'connectivity'
|
||||||
|
|
||||||
SCAN_INTERVAL = timedelta(minutes=5)
|
SCAN_INTERVAL = timedelta(minutes=5)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class PingBinarySensor(BinarySensorDevice):
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return DEFAULT_SENSOR_CLASS
|
return DEFAULT_DEVICE_CLASS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
|
|
@ -14,11 +14,10 @@ from homeassistant.components.binary_sensor import (
|
||||||
from homeassistant.components.sensor.rest import RestData
|
from homeassistant.components.sensor.rest import RestData
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PAYLOAD, CONF_NAME, CONF_VALUE_TEMPLATE, CONF_METHOD, CONF_RESOURCE,
|
CONF_PAYLOAD, CONF_NAME, CONF_VALUE_TEMPLATE, CONF_METHOD, CONF_RESOURCE,
|
||||||
CONF_SENSOR_CLASS, CONF_VERIFY_SSL, CONF_USERNAME, CONF_PASSWORD,
|
CONF_VERIFY_SSL, CONF_USERNAME, CONF_PASSWORD,
|
||||||
CONF_HEADERS, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
|
CONF_HEADERS, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
|
||||||
HTTP_DIGEST_AUTHENTICATION, CONF_DEVICE_CLASS)
|
HTTP_DIGEST_AUTHENTICATION, CONF_DEVICE_CLASS)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -35,7 +34,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_PASSWORD): cv.string,
|
vol.Optional(CONF_PASSWORD): cv.string,
|
||||||
vol.Optional(CONF_PAYLOAD): cv.string,
|
vol.Optional(CONF_PAYLOAD): cv.string,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
vol.Optional(CONF_USERNAME): cv.string,
|
vol.Optional(CONF_USERNAME): cv.string,
|
||||||
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
|
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
|
||||||
|
@ -53,7 +51,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
headers = config.get(CONF_HEADERS)
|
headers = config.get(CONF_HEADERS)
|
||||||
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
device_class = config.get(CONF_DEVICE_CLASS)
|
||||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||||
if value_template is not None:
|
if value_template is not None:
|
||||||
value_template.hass = hass
|
value_template.hass = hass
|
||||||
|
|
|
@ -15,11 +15,9 @@ from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASSES_SCHEMA)
|
DEVICE_CLASSES_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_FRIENDLY_NAME, ATTR_ENTITY_ID, CONF_VALUE_TEMPLATE,
|
ATTR_FRIENDLY_NAME, ATTR_ENTITY_ID, CONF_VALUE_TEMPLATE,
|
||||||
CONF_SENSOR_CLASS, CONF_SENSORS, CONF_DEVICE_CLASS,
|
CONF_SENSORS, CONF_DEVICE_CLASS, EVENT_HOMEASSISTANT_START, STATE_ON)
|
||||||
EVENT_HOMEASSISTANT_START, STATE_ON)
|
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
from homeassistant.helpers.entity import async_generate_entity_id
|
from homeassistant.helpers.entity import async_generate_entity_id
|
||||||
from homeassistant.helpers.event import async_track_state_change
|
from homeassistant.helpers.event import async_track_state_change
|
||||||
from homeassistant.helpers.restore_state import async_get_last_state
|
from homeassistant.helpers.restore_state import async_get_last_state
|
||||||
|
@ -30,7 +28,6 @@ SENSOR_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
|
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
|
||||||
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
|
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -49,8 +46,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
entity_ids = (device_config.get(ATTR_ENTITY_ID) or
|
entity_ids = (device_config.get(ATTR_ENTITY_ID) or
|
||||||
value_template.extract_entities())
|
value_template.extract_entities())
|
||||||
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
|
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
|
||||||
device_class = get_deprecated(
|
device_class = device_config.get(CONF_DEVICE_CLASS)
|
||||||
device_config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
|
||||||
|
|
||||||
if value_template is not None:
|
if value_template is not None:
|
||||||
value_template.hass = hass
|
value_template.hass = hass
|
||||||
|
|
|
@ -13,10 +13,9 @@ import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
|
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, CONF_ENTITY_ID, CONF_TYPE, STATE_UNKNOWN, CONF_SENSOR_CLASS,
|
CONF_NAME, CONF_ENTITY_ID, CONF_TYPE, STATE_UNKNOWN,
|
||||||
ATTR_ENTITY_ID, CONF_DEVICE_CLASS)
|
ATTR_ENTITY_ID, CONF_DEVICE_CLASS)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
from homeassistant.helpers.event import async_track_state_change
|
from homeassistant.helpers.event import async_track_state_change
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -38,7 +37,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_THRESHOLD): vol.Coerce(float),
|
vol.Required(CONF_THRESHOLD): vol.Coerce(float),
|
||||||
vol.Required(CONF_TYPE): vol.In(SENSOR_TYPES),
|
vol.Required(CONF_TYPE): vol.In(SENSOR_TYPES),
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -50,7 +48,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
threshold = config.get(CONF_THRESHOLD)
|
threshold = config.get(CONF_THRESHOLD)
|
||||||
limit_type = config.get(CONF_TYPE)
|
limit_type = config.get(CONF_TYPE)
|
||||||
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
device_class = config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
async_add_devices(
|
async_add_devices(
|
||||||
[ThresholdSensor(hass, entity_id, name, threshold, limit_type,
|
[ThresholdSensor(hass, entity_id, name, threshold, limit_type,
|
||||||
|
|
|
@ -16,9 +16,7 @@ from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorDevice, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
|
BinarySensorDevice, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
|
||||||
DEVICE_CLASSES_SCHEMA)
|
DEVICE_CLASSES_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_FRIENDLY_NAME, ATTR_ENTITY_ID, CONF_SENSOR_CLASS,
|
ATTR_FRIENDLY_NAME, ATTR_ENTITY_ID, CONF_DEVICE_CLASS, STATE_UNKNOWN)
|
||||||
CONF_DEVICE_CLASS, STATE_UNKNOWN,)
|
|
||||||
from homeassistant.helpers.deprecation import get_deprecated
|
|
||||||
from homeassistant.helpers.entity import generate_entity_id
|
from homeassistant.helpers.entity import generate_entity_id
|
||||||
from homeassistant.helpers.event import track_state_change
|
from homeassistant.helpers.event import track_state_change
|
||||||
|
|
||||||
|
@ -32,7 +30,6 @@ SENSOR_SCHEMA = vol.Schema({
|
||||||
vol.Optional(CONF_ATTRIBUTE): cv.string,
|
vol.Optional(CONF_ATTRIBUTE): cv.string,
|
||||||
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
|
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
|
||||||
vol.Optional(CONF_INVERT, default=False): cv.boolean,
|
vol.Optional(CONF_INVERT, default=False): cv.boolean,
|
||||||
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -50,8 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
entity_id = device_config[ATTR_ENTITY_ID]
|
entity_id = device_config[ATTR_ENTITY_ID]
|
||||||
attribute = device_config.get(CONF_ATTRIBUTE)
|
attribute = device_config.get(CONF_ATTRIBUTE)
|
||||||
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
|
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
|
||||||
device_class = get_deprecated(
|
device_class = device_config.get(CONF_DEVICE_CLASS)
|
||||||
device_config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
|
|
||||||
invert = device_config[CONF_INVERT]
|
invert = device_config[CONF_INVERT]
|
||||||
|
|
||||||
sensors.append(
|
sensors.append(
|
||||||
|
|
|
@ -34,5 +34,5 @@ class VolvoSensor(VolvoEntity, BinarySensorDevice):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this sensor, from SENSOR_CLASSES."""
|
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
||||||
return 'safety'
|
return 'safety'
|
||||||
|
|
|
@ -139,7 +139,6 @@ CONF_RESOURCES = 'resources'
|
||||||
CONF_RGB = 'rgb'
|
CONF_RGB = 'rgb'
|
||||||
CONF_SCAN_INTERVAL = 'scan_interval'
|
CONF_SCAN_INTERVAL = 'scan_interval'
|
||||||
CONF_SENDER = 'sender'
|
CONF_SENDER = 'sender'
|
||||||
CONF_SENSOR_CLASS = 'sensor_class'
|
|
||||||
CONF_SENSOR_TYPE = 'sensor_type'
|
CONF_SENSOR_TYPE = 'sensor_type'
|
||||||
CONF_SENSORS = 'sensors'
|
CONF_SENSORS = 'sensors'
|
||||||
CONF_SLAVE = 'slave'
|
CONF_SLAVE = 'slave'
|
||||||
|
|
Loading…
Reference in New Issue