diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index d69d6991ff0..e4fb4542205 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -23,7 +23,6 @@ from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.restore_state import async_restore_state import homeassistant.util.color as color_util DOMAIN = "light" @@ -140,14 +139,6 @@ PROFILE_SCHEMA = vol.Schema( _LOGGER = logging.getLogger(__name__) -def extract_info(state): - """Extract light parameters from a state object.""" - params = {key: state.attributes[key] for key in PROP_TO_ATTR - if key in state.attributes} - params['is_on'] = state.state == STATE_ON - return params - - @bind_hass def is_on(hass, entity_id=None): """Return if the lights are on based on the statemachine.""" @@ -431,9 +422,3 @@ class Light(ToggleEntity): def supported_features(self): """Flag supported features.""" return 0 - - @asyncio.coroutine - def async_added_to_hass(self): - """Component added, restore_state using platforms.""" - if hasattr(self, 'async_restore_state'): - yield from async_restore_state(self, extract_info) diff --git a/homeassistant/components/light/demo.py b/homeassistant/components/light/demo.py index 22ab404a3b2..d01611716eb 100644 --- a/homeassistant/components/light/demo.py +++ b/homeassistant/components/light/demo.py @@ -4,7 +4,6 @@ Demo light platform that implements lights. For more details about this platform, please refer to the documentation https://home-assistant.io/components/demo/ """ -import asyncio import random from homeassistant.components.light import ( @@ -150,26 +149,3 @@ class DemoLight(Light): # As we have disabled polling, we need to inform # Home Assistant about updates in our state ourselves. self.schedule_update_ha_state() - - @asyncio.coroutine - def async_restore_state(self, is_on, **kwargs): - """Restore the demo state.""" - self._state = is_on - - if 'brightness' in kwargs: - self._brightness = kwargs['brightness'] - - if 'color_temp' in kwargs: - self._ct = kwargs['color_temp'] - - if 'rgb_color' in kwargs: - self._rgb = kwargs['rgb_color'] - - if 'xy_color' in kwargs: - self._xy_color = kwargs['xy_color'] - - if 'white_value' in kwargs: - self._white = kwargs['white_value'] - - if 'effect' in kwargs: - self._effect = kwargs['effect'] diff --git a/tests/components/light/test_demo.py b/tests/components/light/test_demo.py index b4576b174d6..8a7d648e6f2 100644 --- a/tests/components/light/test_demo.py +++ b/tests/components/light/test_demo.py @@ -1,14 +1,11 @@ """The tests for the demo light component.""" # pylint: disable=protected-access -import asyncio import unittest -from homeassistant.core import State, CoreState -from homeassistant.setup import setup_component, async_setup_component +from homeassistant.setup import setup_component import homeassistant.components.light as light -from homeassistant.helpers.restore_state import DATA_RESTORE_CACHE -from tests.common import get_test_home_assistant, mock_component +from tests.common import get_test_home_assistant ENTITY_LIGHT = 'light.bed_light' @@ -79,36 +76,3 @@ class TestDemoLight(unittest.TestCase): light.turn_off(self.hass) self.hass.block_till_done() self.assertFalse(light.is_on(self.hass, ENTITY_LIGHT)) - - -@asyncio.coroutine -def test_restore_state(hass): - """Test state gets restored.""" - mock_component(hass, 'recorder') - hass.state = CoreState.starting - hass.data[DATA_RESTORE_CACHE] = { - 'light.bed_light': State('light.bed_light', 'on', { - 'brightness': 'value-brightness', - 'color_temp': 'value-color_temp', - 'rgb_color': 'value-rgb_color', - 'xy_color': 'value-xy_color', - 'white_value': 'value-white_value', - 'effect': 'value-effect', - }), - } - - yield from async_setup_component(hass, 'light', { - 'light': { - 'platform': 'demo', - }}) - - state = hass.states.get('light.bed_light') - assert state is not None - assert state.entity_id == 'light.bed_light' - assert state.state == 'on' - assert state.attributes.get('brightness') == 'value-brightness' - assert state.attributes.get('color_temp') == 'value-color_temp' - assert state.attributes.get('rgb_color') == 'value-rgb_color' - assert state.attributes.get('xy_color') == 'value-xy_color' - assert state.attributes.get('white_value') == 'value-white_value' - assert state.attributes.get('effect') == 'value-effect'