diff --git a/homeassistant/components/template/__init__.py b/homeassistant/components/template/__init__.py index 079569a9324..cc8862afcf4 100644 --- a/homeassistant/components/template/__init__.py +++ b/homeassistant/components/template/__init__.py @@ -7,13 +7,11 @@ from .const import DOMAIN, EVENT_TEMPLATE_RELOADED, PLATFORMS async def async_setup_reload_service(hass): """Create the reload service for the template domain.""" - if hass.services.has_service(DOMAIN, SERVICE_RELOAD): return async def _reload_config(call): """Reload the template platform config.""" - await async_reload_integration_platforms(hass, DOMAIN, PLATFORMS) hass.bus.async_fire(EVENT_TEMPLATE_RELOADED, context=call.context) diff --git a/homeassistant/components/template/alarm_control_panel.py b/homeassistant/components/template/alarm_control_panel.py index ccefab767be..f56c5b27572 100644 --- a/homeassistant/components/template/alarm_control_panel.py +++ b/homeassistant/components/template/alarm_control_panel.py @@ -81,7 +81,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( async def _async_create_entities(hass, config): """Create Template Alarm Control Panels.""" - alarm_control_panels = [] for device, device_config in config[CONF_ALARM_CONTROL_PANELS].items(): @@ -114,7 +113,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Template Alarm Control Panels.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) diff --git a/homeassistant/components/template/binary_sensor.py b/homeassistant/components/template/binary_sensor.py index f996b91a61e..b810c7faee1 100644 --- a/homeassistant/components/template/binary_sensor.py +++ b/homeassistant/components/template/binary_sensor.py @@ -97,7 +97,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template binary sensors.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -141,7 +140,6 @@ class BinarySensorTemplate(TemplateEntity, BinarySensorEntity): async def async_added_to_hass(self): """Register callbacks.""" - self.add_template_attribute("_state", self._template, None, self._update_state) if self._delay_on_raw is not None: diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index 93ffd2fd988..278cd1c80bb 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -20,6 +20,7 @@ from homeassistant.components.cover import ( CoverEntity, ) from homeassistant.const import ( + CONF_COVERS, CONF_DEVICE_CLASS, CONF_ENTITY_ID, CONF_ENTITY_PICTURE_TEMPLATE, @@ -53,8 +54,6 @@ _VALID_STATES = [ "false", ] -CONF_COVERS = "covers" - CONF_POSITION_TEMPLATE = "position_template" CONF_TILT_TEMPLATE = "tilt_template" OPEN_ACTION = "open_cover" @@ -161,7 +160,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Template cover.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -228,7 +226,6 @@ class CoverTemplate(TemplateEntity, CoverEntity): async def async_added_to_hass(self): """Register callbacks.""" - if self._template: self.add_template_attribute( "_position", self._template, None, self._update_state diff --git a/homeassistant/components/template/fan.py b/homeassistant/components/template/fan.py index 5d01790f21a..ac77b3dc333 100644 --- a/homeassistant/components/template/fan.py +++ b/homeassistant/components/template/fan.py @@ -159,7 +159,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template fans.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) diff --git a/homeassistant/components/template/light.py b/homeassistant/components/template/light.py index 42493136b48..0edaacbb5ca 100644 --- a/homeassistant/components/template/light.py +++ b/homeassistant/components/template/light.py @@ -137,7 +137,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template lights.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -259,7 +258,6 @@ class LightTemplate(TemplateEntity, LightEntity): async def async_added_to_hass(self): """Register callbacks.""" - if self._template: self.add_template_attribute( "_state", self._template, None, self._update_state @@ -404,7 +402,6 @@ class LightTemplate(TemplateEntity, LightEntity): @callback def _update_state(self, result): """Update the state from the template.""" - if isinstance(result, TemplateError): # This behavior is legacy self._state = False @@ -431,7 +428,6 @@ class LightTemplate(TemplateEntity, LightEntity): @callback def _update_temperature(self, render): """Update the temperature from the template.""" - try: if render in ("None", ""): self._temperature = None diff --git a/homeassistant/components/template/lock.py b/homeassistant/components/template/lock.py index 2cd8bc00266..692f06e28fe 100644 --- a/homeassistant/components/template/lock.py +++ b/homeassistant/components/template/lock.py @@ -60,7 +60,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template lock.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -129,7 +128,6 @@ class TemplateLock(TemplateEntity, LockEntity): async def async_added_to_hass(self): """Register callbacks.""" - self.add_template_attribute( "_state", self._state_template, None, self._update_state ) diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index aea14884812..c67e3a275a3 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -59,7 +59,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( async def _async_create_entities(hass, config): """Create the template sensors.""" - sensors = [] for device, device_config in config[CONF_SENSORS].items(): @@ -96,7 +95,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template sensors.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -140,7 +138,6 @@ class SensorTemplate(TemplateEntity, Entity): async def async_added_to_hass(self): """Register callbacks.""" - self.add_template_attribute("_state", self._template, None, self._update_state) if self._friendly_name_template is not None: self.add_template_attribute("_name", self._friendly_name_template) diff --git a/homeassistant/components/template/switch.py b/homeassistant/components/template/switch.py index 511338b5aa1..412c4507d1f 100644 --- a/homeassistant/components/template/switch.py +++ b/homeassistant/components/template/switch.py @@ -90,7 +90,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template switches.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -147,7 +146,6 @@ class SwitchTemplate(TemplateEntity, SwitchEntity, RestoreEntity): async def async_added_to_hass(self): """Register callbacks.""" - if self._template is None: # restore state after startup diff --git a/homeassistant/components/template/template_entity.py b/homeassistant/components/template/template_entity.py index 49b0edfab02..f350eb87d61 100644 --- a/homeassistant/components/template/template_entity.py +++ b/homeassistant/components/template/template_entity.py @@ -223,7 +223,6 @@ class TemplateEntity(Entity): updates: List[TrackTemplateResult], ) -> None: """Call back the results to the attributes.""" - if event: self.async_set_context(event.context) diff --git a/homeassistant/components/template/vacuum.py b/homeassistant/components/template/vacuum.py index 5bf8148b96e..171aeb7af92 100644 --- a/homeassistant/components/template/vacuum.py +++ b/homeassistant/components/template/vacuum.py @@ -147,7 +147,6 @@ async def _async_create_entities(hass, config): async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the template vacuums.""" - await async_setup_reload_service(hass, DOMAIN, PLATFORMS) async_add_entities(await _async_create_entities(hass, config)) @@ -337,7 +336,6 @@ class TemplateVacuum(TemplateEntity, StateVacuumEntity): async def async_added_to_hass(self): """Register callbacks.""" - if self._template is not None: self.add_template_attribute( "_state", self._template, None, self._update_state