mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 21:40:16 +00:00
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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user