Remove deprecated YAML configuration from Fronius (#69032)
parent
beb54dfb63
commit
e69450f7ca
|
@ -10,7 +10,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||
from homeassistant.const import CONF_HOST, CONF_RESOURCE
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
@ -110,10 +110,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_import(self, conf: dict) -> FlowResult:
|
||||
"""Import a configuration from config.yaml."""
|
||||
return await self.async_step_user(user_input={CONF_HOST: conf[CONF_RESOURCE]})
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle a flow initiated by the DHCP client."""
|
||||
for entry in self._async_current_entries(include_ignore=False):
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
"""Support for Fronius devices."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, Final
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
PLATFORM_SCHEMA,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_RESOURCE,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_WATT_HOUR,
|
||||
|
@ -29,10 +23,8 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -49,38 +41,8 @@ if TYPE_CHECKING:
|
|||
FroniusStorageUpdateCoordinator,
|
||||
)
|
||||
|
||||
_LOGGER: Final = logging.getLogger(__name__)
|
||||
|
||||
ENERGY_VOLT_AMPERE_REACTIVE_HOUR: Final = "varh"
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_RESOURCE): cv.url,
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS): object,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Import Fronius configuration from yaml."""
|
||||
_LOGGER.warning(
|
||||
"Loading Fronius via platform setup is deprecated. Please remove it from your yaml configuration"
|
||||
)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=config,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
|
|
@ -7,17 +7,15 @@ import pytest
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||
from homeassistant.components.fronius.const import DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_RESOURCE
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import (
|
||||
RESULT_TYPE_ABORT,
|
||||
RESULT_TYPE_CREATE_ENTRY,
|
||||
RESULT_TYPE_FORM,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import MOCK_HOST, mock_responses
|
||||
from . import mock_responses
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -260,32 +258,6 @@ async def test_form_updates_host(hass, aioclient_mock):
|
|||
}
|
||||
|
||||
|
||||
async def test_import(hass, aioclient_mock):
|
||||
"""Test import step."""
|
||||
mock_responses(aioclient_mock)
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
SENSOR_DOMAIN,
|
||||
{
|
||||
SENSOR_DOMAIN: {
|
||||
"platform": DOMAIN,
|
||||
CONF_RESOURCE: MOCK_HOST,
|
||||
}
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
fronius_entries = hass.config_entries.async_entries(DOMAIN)
|
||||
assert len(fronius_entries) == 1
|
||||
|
||||
test_entry = fronius_entries[0]
|
||||
assert test_entry.unique_id == "123.4567890" # has to match mocked logger unique_id
|
||||
assert test_entry.data == {
|
||||
"host": MOCK_HOST,
|
||||
"is_logger": True,
|
||||
}
|
||||
|
||||
|
||||
async def test_dhcp(hass, aioclient_mock):
|
||||
"""Test starting a flow from discovery."""
|
||||
with patch(
|
||||
|
|
Loading…
Reference in New Issue