Sensor device classes (#14282)

* Added light device class, moved device classes to const

* Removed unnecessary icons

* Replace 'lux' with 'lx'

* Fix comment

* Changed device_class name
This commit is contained in:
cdce8p 2018-05-05 15:37:40 +02:00 committed by Paulus Schoutsen
parent ec3ce4c80d
commit 95d27bd1fa
19 changed files with 92 additions and 79 deletions

View file

@ -10,7 +10,7 @@ import os
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_NAME
from homeassistant.const import CONF_NAME, DEVICE_CLASS_BATTERY
from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv
@ -48,8 +48,6 @@ DEFAULT_SYSTEM = 'linux'
SYSTEMS = ['android', 'linux']
ICON = 'mdi:battery'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_BATTERY, default=DEFAULT_BATTERY): cv.positive_int,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
@ -97,7 +95,7 @@ class LinuxBatterySensor(Entity):
@property
def device_class(self):
"""Return the device class of the sensor."""
return 'battery'
return DEVICE_CLASS_BATTERY
@property
def state(self):
@ -109,11 +107,6 @@ class LinuxBatterySensor(Entity):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
@property
def device_state_attributes(self):
"""Return the state attributes of the sensor."""