Remove deprecated YAML configuration from Growatt (#54325)
This commit is contained in:
parent
c79ee53ab1
commit
1c7891fbee
3 changed files with 2 additions and 57 deletions
|
@ -76,7 +76,3 @@ class GrowattServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self._abort_if_unique_id_configured()
|
||||
self.data.update(user_input)
|
||||
return self.async_create_entry(title=self.data[CONF_NAME], data=self.data)
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
"""Migrate old yaml config to config flow."""
|
||||
return await self.async_step_user(import_data)
|
||||
|
|
|
@ -5,10 +5,8 @@ import logging
|
|||
import re
|
||||
|
||||
import growattServer
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
|
@ -31,10 +29,9 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle, dt
|
||||
|
||||
from .const import CONF_PLANT_ID, DEFAULT_NAME, DEFAULT_PLANT_ID, DEFAULT_URL, DOMAIN
|
||||
from .const import CONF_PLANT_ID, DEFAULT_PLANT_ID, DEFAULT_URL
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -549,30 +546,6 @@ SENSOR_TYPES = {
|
|||
**MIX_SENSOR_TYPES,
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_PLANT_ID, default=DEFAULT_PLANT_ID): cv.string,
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Required(CONF_URL, default=DEFAULT_URL): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up growatt server from yaml."""
|
||||
if not hass.config_entries.async_entries(DOMAIN):
|
||||
_LOGGER.warning(
|
||||
"Loading Growatt via platform setup is deprecated."
|
||||
"Please remove it from your configuration"
|
||||
)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_device_list(api, config):
|
||||
"""Retrieve the device list for the selected plant."""
|
||||
|
|
|
@ -149,30 +149,6 @@ async def test_one_plant_on_account(hass):
|
|||
assert result["data"][CONF_PLANT_ID] == "123456"
|
||||
|
||||
|
||||
async def test_import_one_plant(hass):
|
||||
"""Test import step with a single plant."""
|
||||
import_data = FIXTURE_USER_INPUT.copy()
|
||||
|
||||
with patch(
|
||||
"growattServer.GrowattApi.login", return_value=GROWATT_LOGIN_RESPONSE
|
||||
), patch(
|
||||
"growattServer.GrowattApi.plant_list",
|
||||
return_value=GROWATT_PLANT_LIST_RESPONSE,
|
||||
), patch(
|
||||
"homeassistant.components.growatt_server.async_setup_entry", return_value=True
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=import_data,
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["data"][CONF_USERNAME] == FIXTURE_USER_INPUT[CONF_USERNAME]
|
||||
assert result["data"][CONF_PASSWORD] == FIXTURE_USER_INPUT[CONF_PASSWORD]
|
||||
assert result["data"][CONF_PLANT_ID] == "123456"
|
||||
|
||||
|
||||
async def test_existing_plant_configured(hass):
|
||||
"""Test entering an existing plant_id."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, unique_id="123456")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue