mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove deprecated yaml config from philips_js (#62471)
This commit is contained in:
parent
71852fd7a8
commit
a9c45fdcc0
@ -47,17 +47,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._hub: PhilipsTV | None = None
|
self._hub: PhilipsTV | None = None
|
||||||
self._pair_state: Any = 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):
|
async def _async_create_current(self):
|
||||||
|
|
||||||
system = self._current[CONF_SYSTEM]
|
system = self._current[CONF_SYSTEM]
|
||||||
|
@ -4,11 +4,9 @@ from __future__ import annotations
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from haphilipsjs import ConnectionFailure
|
from haphilipsjs import ConnectionFailure
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
PLATFORM_SCHEMA,
|
|
||||||
BrowseMedia,
|
BrowseMedia,
|
||||||
MediaPlayerDeviceClass,
|
MediaPlayerDeviceClass,
|
||||||
MediaPlayerEntity,
|
MediaPlayerEntity,
|
||||||
@ -36,15 +34,8 @@ from homeassistant.components.media_player.const import (
|
|||||||
SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_STEP,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.errors import BrowseError
|
from homeassistant.components.media_player.errors import BrowseError
|
||||||
from homeassistant.const import (
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
CONF_API_VERSION,
|
|
||||||
CONF_HOST,
|
|
||||||
CONF_NAME,
|
|
||||||
STATE_OFF,
|
|
||||||
STATE_ON,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
@ -68,41 +59,11 @@ SUPPORT_PHILIPS_JS = (
|
|||||||
|
|
||||||
CONF_ON_ACTION = "turn_on_action"
|
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):
|
def _inverted(data):
|
||||||
return {v: k for k, v in data.items()}
|
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(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: config_entries.ConfigEntry,
|
||||||
|
@ -58,8 +58,6 @@ MOCK_USERINPUT = {
|
|||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_IMPORT = {"host": "1.1.1.1", "api_version": 6}
|
|
||||||
|
|
||||||
MOCK_CONFIG = {
|
MOCK_CONFIG = {
|
||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
"api_version": 1,
|
"api_version": 1,
|
||||||
|
@ -10,7 +10,6 @@ from homeassistant.components.philips_js.const import CONF_ALLOW_NOTIFY, DOMAIN
|
|||||||
from . import (
|
from . import (
|
||||||
MOCK_CONFIG,
|
MOCK_CONFIG,
|
||||||
MOCK_CONFIG_PAIRED,
|
MOCK_CONFIG_PAIRED,
|
||||||
MOCK_IMPORT,
|
|
||||||
MOCK_PASSWORD,
|
MOCK_PASSWORD,
|
||||||
MOCK_SYSTEM_UNPAIRED,
|
MOCK_SYSTEM_UNPAIRED,
|
||||||
MOCK_USERINPUT,
|
MOCK_USERINPUT,
|
||||||
@ -45,32 +44,6 @@ async def mock_tv_pairable(mock_tv):
|
|||||||
return 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):
|
async def test_form(hass, mock_setup_entry):
|
||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user