Minor cleanup - Define 'CONF_ICON_TEMPLATE' constant centrally (#7910)

* Add 'icon_template' to switch templates (similar to sensor template)

* Add test for template switch 'icon_template'

* Define 'CONF_ICON_TEMPLATE' constant centrally

* Missed a redundant definition
This commit is contained in:
PhracturedBlue authored and Fabian Affolter committed 2017-06-05 17:33:57 +02:00
1 parent f303f6a191
commit 2b850f417e
3 files changed
+5 -7

No files matched your search

+2 -3
View File
@@ -13,7 +13,8 @@ from homeassistant.core import callback
from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA
from homeassistant.const import (
ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE,
ATTR_ENTITY_ID, CONF_SENSORS, EVENT_HOMEASSISTANT_START)
CONF_ICON_TEMPLATE, ATTR_ENTITY_ID, CONF_SENSORS,
EVENT_HOMEASSISTANT_START)
from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity, async_generate_entity_id
@@ -22,8 +23,6 @@ from homeassistant.helpers.restore_state import async_get_last_state
_LOGGER = logging.getLogger(__name__)
CONF_ICON_TEMPLATE = 'icon_template'
SENSOR_SCHEMA = vol.Schema({
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
vol.Optional(CONF_ICON_TEMPLATE): cv.template,