From 2f6bdc864375294cb42d17f008aca7483294378d Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 30 Aug 2019 16:41:07 -0700 Subject: [PATCH] Remove deprecated SMA config (#26306) --- homeassistant/components/sma/sensor.py | 25 ------------------------- tests/components/sma/test_sensor.py | 18 ------------------ 2 files changed, 43 deletions(-) diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index 34aed146cf0..5b6bc57be9d 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -19,7 +19,6 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval -from homeassistant.const import MINOR_VERSION, MAJOR_VERSION _LOGGER = logging.getLogger(__name__) @@ -31,7 +30,6 @@ CONF_SENSORS = "sensors" CONF_UNIT = "unit" GROUPS = ["user", "installer"] -OLD_CONFIG_DEPRECATED = MAJOR_VERSION > 0 or MINOR_VERSION > 98 def _check_sensor_schema(conf): @@ -45,29 +43,6 @@ def _check_sensor_schema(conf): customs = list(conf[CONF_CUSTOM].keys()) - if isinstance(conf[CONF_SENSORS], dict): - msg = '"sensors" should be a simple list from 0.99' - if OLD_CONFIG_DEPRECATED: - raise vol.Invalid(msg) - _LOGGER.warning(msg) - valid.extend(customs) - - for sname, attrs in conf[CONF_SENSORS].items(): - if sname not in valid: - raise vol.Invalid("{} does not exist".format(sname)) - if attrs: - _LOGGER.warning( - "Attributes on sensors will be deprecated in 0.99. Start using only individual sensors: %s: %s", - sname, - ", ".join(attrs), - ) - for attr in attrs: - if attr in valid: - continue - raise vol.Invalid("{} does not exist [{}]".format(attr, sname)) - return conf - - # Sensors is a list (only option from from 0.99) for sensor in conf[CONF_SENSORS]: if sensor in customs: _LOGGER.warning( diff --git a/tests/components/sma/test_sensor.py b/tests/components/sma/test_sensor.py index bee1743791c..3caf889c522 100644 --- a/tests/components/sma/test_sensor.py +++ b/tests/components/sma/test_sensor.py @@ -15,24 +15,6 @@ BASE_CFG = { } -async def test_sma_config_old(hass): - """Test old config.""" - sensors = {"current_consumption": ["current_consumption"]} - - with assert_setup_component(1): - assert await async_setup_component( - hass, DOMAIN, {DOMAIN: dict(BASE_CFG, sensors=sensors)} - ) - - state = hass.states.get("sensor.current_consumption") - assert state - assert "unit_of_measurement" in state.attributes - assert "current_consumption" in state.attributes - - state = hass.states.get("sensor.my_sensor") - assert not state - - async def test_sma_config(hass): """Test new config.""" sensors = ["current_consumption"]