From a9c45fdcc0b22c81fa376113960f23288a3903a1 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Tue, 21 Dec 2021 05:11:25 -0500 Subject: [PATCH] Remove deprecated yaml config from philips_js (#62471) --- .../components/philips_js/config_flow.py | 11 ----- .../components/philips_js/media_player.py | 41 +------------------ tests/components/philips_js/__init__.py | 2 - .../components/philips_js/test_config_flow.py | 27 ------------ 4 files changed, 1 insertion(+), 80 deletions(-) diff --git a/homeassistant/components/philips_js/config_flow.py b/homeassistant/components/philips_js/config_flow.py index 59403b2ec86..89f13ffadbf 100644 --- a/homeassistant/components/philips_js/config_flow.py +++ b/homeassistant/components/philips_js/config_flow.py @@ -47,17 +47,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._hub: PhilipsTV | None = None self._pair_state: Any = None - async def async_step_import(self, conf: dict) -> dict: - """Import a configuration from config.yaml.""" - self._async_abort_entries_match({CONF_HOST: conf[CONF_HOST]}) - - return await self.async_step_user( - { - CONF_HOST: conf[CONF_HOST], - CONF_API_VERSION: conf[CONF_API_VERSION], - } - ) - async def _async_create_current(self): system = self._current[CONF_SYSTEM] diff --git a/homeassistant/components/philips_js/media_player.py b/homeassistant/components/philips_js/media_player.py index 8e9ddfc353f..fa5643503bc 100644 --- a/homeassistant/components/philips_js/media_player.py +++ b/homeassistant/components/philips_js/media_player.py @@ -4,11 +4,9 @@ from __future__ import annotations from typing import Any from haphilipsjs import ConnectionFailure -import voluptuous as vol from homeassistant import config_entries from homeassistant.components.media_player import ( - PLATFORM_SCHEMA, BrowseMedia, MediaPlayerDeviceClass, MediaPlayerEntity, @@ -36,15 +34,8 @@ from homeassistant.components.media_player.const import ( SUPPORT_VOLUME_STEP, ) from homeassistant.components.media_player.errors import BrowseError -from homeassistant.const import ( - CONF_API_VERSION, - CONF_HOST, - CONF_NAME, - STATE_OFF, - STATE_ON, -) +from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant, callback -import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -68,41 +59,11 @@ SUPPORT_PHILIPS_JS = ( CONF_ON_ACTION = "turn_on_action" -DEFAULT_API_VERSION = 1 - -PLATFORM_SCHEMA = vol.All( - cv.deprecated(CONF_HOST), - cv.deprecated(CONF_NAME), - cv.deprecated(CONF_API_VERSION), - cv.deprecated(CONF_ON_ACTION), - PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_HOST): cv.string, - vol.Remove(CONF_NAME): cv.string, - vol.Optional(CONF_API_VERSION, default=DEFAULT_API_VERSION): vol.Coerce( - int - ), - vol.Remove(CONF_ON_ACTION): cv.SCRIPT_SCHEMA, - } - ), -) - def _inverted(data): return {v: k for k, v in data.items()} -async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): - """Set up the Philips TV platform.""" - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=config, - ) - ) - - async def async_setup_entry( hass: HomeAssistant, config_entry: config_entries.ConfigEntry, diff --git a/tests/components/philips_js/__init__.py b/tests/components/philips_js/__init__.py index 9dea390a600..f524a586fc8 100644 --- a/tests/components/philips_js/__init__.py +++ b/tests/components/philips_js/__init__.py @@ -58,8 +58,6 @@ MOCK_USERINPUT = { "host": "1.1.1.1", } -MOCK_IMPORT = {"host": "1.1.1.1", "api_version": 6} - MOCK_CONFIG = { "host": "1.1.1.1", "api_version": 1, diff --git a/tests/components/philips_js/test_config_flow.py b/tests/components/philips_js/test_config_flow.py index f3ab44844a2..ace62195115 100644 --- a/tests/components/philips_js/test_config_flow.py +++ b/tests/components/philips_js/test_config_flow.py @@ -10,7 +10,6 @@ from homeassistant.components.philips_js.const import CONF_ALLOW_NOTIFY, DOMAIN from . import ( MOCK_CONFIG, MOCK_CONFIG_PAIRED, - MOCK_IMPORT, MOCK_PASSWORD, MOCK_SYSTEM_UNPAIRED, MOCK_USERINPUT, @@ -45,32 +44,6 @@ async def mock_tv_pairable(mock_tv): return mock_tv -async def test_import(hass, mock_setup_entry): - """Test we get an item on import.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_IMPORT, - ) - - assert result["type"] == "create_entry" - assert result["title"] == "Philips TV (1234567890)" - assert result["data"] == MOCK_CONFIG - assert len(mock_setup_entry.mock_calls) == 1 - - -async def test_import_exist(hass, mock_config_entry): - """Test we get an item on import.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data=MOCK_IMPORT, - ) - - assert result["type"] == "abort" - assert result["reason"] == "already_configured" - - async def test_form(hass, mock_setup_entry): """Test we get the form.""" result = await hass.config_entries.flow.async_init(