mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
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:
parent
f303f6a191
commit
2b850f417e
@ -13,7 +13,8 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA
|
from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE,
|
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
|
from homeassistant.exceptions import TemplateError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity, async_generate_entity_id
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_ICON_TEMPLATE = 'icon_template'
|
|
||||||
|
|
||||||
SENSOR_SCHEMA = vol.Schema({
|
SENSOR_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
|
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
|
||||||
vol.Optional(CONF_ICON_TEMPLATE): cv.template,
|
vol.Optional(CONF_ICON_TEMPLATE): cv.template,
|
||||||
|
@ -13,8 +13,8 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.components.switch import (
|
from homeassistant.components.switch import (
|
||||||
ENTITY_ID_FORMAT, SwitchDevice, PLATFORM_SCHEMA)
|
ENTITY_ID_FORMAT, SwitchDevice, PLATFORM_SCHEMA)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_FRIENDLY_NAME, CONF_VALUE_TEMPLATE, STATE_OFF, STATE_ON,
|
ATTR_FRIENDLY_NAME, CONF_VALUE_TEMPLATE, CONF_ICON_TEMPLATE, STATE_OFF,
|
||||||
ATTR_ENTITY_ID, CONF_SWITCHES, EVENT_HOMEASSISTANT_START)
|
STATE_ON, ATTR_ENTITY_ID, CONF_SWITCHES, EVENT_HOMEASSISTANT_START)
|
||||||
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.entity import async_generate_entity_id
|
from homeassistant.helpers.entity import async_generate_entity_id
|
||||||
@ -25,8 +25,6 @@ from homeassistant.helpers.script import Script
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
_VALID_STATES = [STATE_ON, STATE_OFF, 'true', 'false']
|
_VALID_STATES = [STATE_ON, STATE_OFF, 'true', 'false']
|
||||||
|
|
||||||
CONF_ICON_TEMPLATE = 'icon_template'
|
|
||||||
|
|
||||||
ON_ACTION = 'turn_on'
|
ON_ACTION = 'turn_on'
|
||||||
OFF_ACTION = 'turn_off'
|
OFF_ACTION = 'turn_off'
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ CONF_HEADERS = 'headers'
|
|||||||
CONF_HOST = 'host'
|
CONF_HOST = 'host'
|
||||||
CONF_HOSTS = 'hosts'
|
CONF_HOSTS = 'hosts'
|
||||||
CONF_ICON = 'icon'
|
CONF_ICON = 'icon'
|
||||||
|
CONF_ICON_TEMPLATE = 'icon_template'
|
||||||
CONF_INCLUDE = 'include'
|
CONF_INCLUDE = 'include'
|
||||||
CONF_ID = 'id'
|
CONF_ID = 'id'
|
||||||
CONF_LATITUDE = 'latitude'
|
CONF_LATITUDE = 'latitude'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user