From 7671ab0bb7a025d8ba03be4aec7ad2bdf950d164 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sat, 4 Nov 2023 16:41:59 +0100 Subject: [PATCH] Remove platform yaml from myStrom (#103378) --- .../components/mystrom/config_flow.py | 4 -- homeassistant/components/mystrom/light.py | 46 +------------------ homeassistant/components/mystrom/switch.py | 46 ++----------------- tests/components/mystrom/test_config_flow.py | 21 --------- 4 files changed, 5 insertions(+), 112 deletions(-) diff --git a/homeassistant/components/mystrom/config_flow.py b/homeassistant/components/mystrom/config_flow.py index 3dc334d8252..6b2fe85bfe8 100644 --- a/homeassistant/components/mystrom/config_flow.py +++ b/homeassistant/components/mystrom/config_flow.py @@ -31,10 +31,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult: - """Handle import from config.""" - return await self.async_step_user(import_config) - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: diff --git a/homeassistant/components/mystrom/light.py b/homeassistant/components/mystrom/light.py index 6a6e7efa1b3..ce9357d23f7 100644 --- a/homeassistant/components/mystrom/light.py +++ b/homeassistant/components/mystrom/light.py @@ -5,25 +5,19 @@ import logging from typing import Any from pymystrom.exceptions import MyStromConnectionError -import voluptuous as vol from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_EFFECT, ATTR_HS_COLOR, - PLATFORM_SCHEMA, ColorMode, LightEntity, LightEntityFeature, ) -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -import homeassistant.helpers.config_validation as cv +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import DOMAIN, MANUFACTURER @@ -34,14 +28,6 @@ DEFAULT_NAME = "myStrom bulb" EFFECT_RAINBOW = "rainbow" EFFECT_SUNRISE = "sunrise" -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_HOST): cv.string, - vol.Required(CONF_MAC): cv.string, - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - } -) - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback @@ -52,34 +38,6 @@ async def async_setup_entry( async_add_entities([MyStromLight(device, entry.title, info["mac"])]) -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the myStrom light integration.""" - async_create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_yaml_{DOMAIN}", - breaks_in_ha_version="2023.12.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "myStrom", - }, - ) - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config - ) - ) - - class MyStromLight(LightEntity): """Representation of the myStrom WiFi bulb.""" diff --git a/homeassistant/components/mystrom/switch.py b/homeassistant/components/mystrom/switch.py index 262ee54101b..8f459e6801e 100644 --- a/homeassistant/components/mystrom/switch.py +++ b/homeassistant/components/mystrom/switch.py @@ -5,17 +5,12 @@ import logging from typing import Any from pymystrom.exceptions import MyStromConnectionError -import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_HOST, CONF_NAME -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -import homeassistant.helpers.config_validation as cv +from homeassistant.components.switch import SwitchEntity +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from .const import DOMAIN, MANUFACTURER @@ -23,13 +18,6 @@ DEFAULT_NAME = "myStrom Switch" _LOGGER = logging.getLogger(__name__) -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_HOST): cv.string, - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - } -) - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback @@ -39,34 +27,6 @@ async def async_setup_entry( async_add_entities([MyStromSwitch(device, entry.title)]) -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the myStrom switch/plug integration.""" - async_create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_yaml_{DOMAIN}", - breaks_in_ha_version="2023.12.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "myStrom", - }, - ) - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config - ) - ) - - class MyStromSwitch(SwitchEntity): """Representation of a myStrom switch/plug.""" diff --git a/tests/components/mystrom/test_config_flow.py b/tests/components/mystrom/test_config_flow.py index 97823681b8e..9459519de75 100644 --- a/tests/components/mystrom/test_config_flow.py +++ b/tests/components/mystrom/test_config_flow.py @@ -6,7 +6,6 @@ import pytest from homeassistant import config_entries from homeassistant.components.mystrom.const import DOMAIN -from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -72,26 +71,6 @@ async def test_form_duplicates( mock_session.assert_called_once() -async def test_step_import(hass: HomeAssistant) -> None: - """Test the import step.""" - conf = { - CONF_HOST: "1.1.1.1", - } - with patch("pymystrom.switch.MyStromSwitch.get_state"), patch( - "pymystrom.get_device_info", - return_value={"type": 101, "mac": DEVICE_MAC}, - ): - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=conf - ) - await hass.async_block_till_done() - assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["title"] == "myStrom Device" - assert result["data"] == { - CONF_HOST: "1.1.1.1", - } - - async def test_wong_answer_from_device(hass: HomeAssistant) -> None: """Test handling of wrong answers from the device."""