From b83ff739bc20e1e43486a0d4186446a19896272a Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Mon, 17 Jul 2017 22:24:05 +0200 Subject: [PATCH] Remove deprecated automation keywords (#8510) * Remove deprecated automation keywords * Remove retired test case * Remove retired keyword --- homeassistant/components/automation/state.py | 8 ++------ homeassistant/components/automation/time.py | 11 ++--------- tests/components/automation/test_state.py | 19 ------------------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/automation/state.py b/homeassistant/components/automation/state.py index fbd1570a1e0..8ad5c40bb80 100644 --- a/homeassistant/components/automation/state.py +++ b/homeassistant/components/automation/state.py @@ -12,13 +12,11 @@ import homeassistant.util.dt as dt_util from homeassistant.const import MATCH_ALL, CONF_PLATFORM from homeassistant.helpers.event import ( async_track_state_change, async_track_point_in_utc_time) -from homeassistant.helpers.deprecation import get_deprecated import homeassistant.helpers.config_validation as cv CONF_ENTITY_ID = 'entity_id' CONF_FROM = 'from' CONF_TO = 'to' -CONF_STATE = 'state' CONF_FOR = 'for' TRIGGER_SCHEMA = vol.All( @@ -28,11 +26,9 @@ TRIGGER_SCHEMA = vol.All( # These are str on purpose. Want to catch YAML conversions CONF_FROM: str, CONF_TO: str, - CONF_STATE: str, CONF_FOR: vol.All(cv.time_period, cv.positive_timedelta), }), - vol.Any(cv.key_dependency(CONF_FOR, CONF_TO), - cv.key_dependency(CONF_FOR, CONF_STATE)) + cv.key_dependency(CONF_FOR, CONF_TO), ) @@ -41,7 +37,7 @@ def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" entity_id = config.get(CONF_ENTITY_ID) from_state = config.get(CONF_FROM, MATCH_ALL) - to_state = get_deprecated(config, CONF_TO, CONF_STATE, MATCH_ALL) + to_state = config.get(CONF_TO, MATCH_ALL) time_delta = config.get(CONF_FOR) async_remove_state_for_cancel = None async_remove_state_for_listener = None diff --git a/homeassistant/components/automation/time.py b/homeassistant/components/automation/time.py index 8ba082e3331..a3a8496c3c5 100644 --- a/homeassistant/components/automation/time.py +++ b/homeassistant/components/automation/time.py @@ -10,7 +10,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -from homeassistant.const import CONF_AT, CONF_PLATFORM, CONF_AFTER +from homeassistant.const import CONF_AT, CONF_PLATFORM from homeassistant.helpers import config_validation as cv from homeassistant.helpers.event import async_track_time_change @@ -23,12 +23,10 @@ _LOGGER = logging.getLogger(__name__) TRIGGER_SCHEMA = vol.All(vol.Schema({ vol.Required(CONF_PLATFORM): 'time', CONF_AT: cv.time, - CONF_AFTER: cv.time, CONF_HOURS: vol.Any(vol.Coerce(int), vol.Coerce(str)), CONF_MINUTES: vol.Any(vol.Coerce(int), vol.Coerce(str)), CONF_SECONDS: vol.Any(vol.Coerce(int), vol.Coerce(str)), -}), cv.has_at_least_one_key(CONF_HOURS, CONF_MINUTES, - CONF_SECONDS, CONF_AT, CONF_AFTER)) +}), cv.has_at_least_one_key(CONF_HOURS, CONF_MINUTES, CONF_SECONDS, CONF_AT)) @asyncio.coroutine @@ -37,11 +35,6 @@ def async_trigger(hass, config, action): if CONF_AT in config: at_time = config.get(CONF_AT) hours, minutes, seconds = at_time.hour, at_time.minute, at_time.second - elif CONF_AFTER in config: - _LOGGER.warning("'after' is deprecated for the time trigger. Please " - "rename 'after' to 'at' in your configuration file.") - at_time = config.get(CONF_AFTER) - hours, minutes, seconds = at_time.hour, at_time.minute, at_time.second else: hours = config.get(CONF_HOURS) minutes = config.get(CONF_MINUTES) diff --git a/tests/components/automation/test_state.py b/tests/components/automation/test_state.py index 28473511e29..2fd6c8415db 100644 --- a/tests/components/automation/test_state.py +++ b/tests/components/automation/test_state.py @@ -130,25 +130,6 @@ class TestAutomationState(unittest.TestCase): self.hass.block_till_done() self.assertEqual(1, len(self.calls)) - def test_if_fires_on_entity_change_with_state_filter(self): - """Test for firing on entity change with state filter.""" - assert setup_component(self.hass, automation.DOMAIN, { - automation.DOMAIN: { - 'trigger': { - 'platform': 'state', - 'entity_id': 'test.entity', - 'state': 'world' - }, - 'action': { - 'service': 'test.automation' - } - } - }) - - self.hass.states.set('test.entity', 'world') - self.hass.block_till_done() - self.assertEqual(1, len(self.calls)) - def test_if_fires_on_entity_change_with_both_filters(self): """Test for firing if both filters are a non match.""" assert setup_component(self.hass, automation.DOMAIN, {