mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove deprecated fibaro yaml config (#87939)
This commit is contained in:
parent
666aace8a2
commit
5f4a2a713c
@ -10,15 +10,11 @@ from pyfibaro.fibaro_client import FibaroClient
|
|||||||
from pyfibaro.fibaro_device import DeviceModel
|
from pyfibaro.fibaro_device import DeviceModel
|
||||||
from pyfibaro.fibaro_scene import SceneModel
|
from pyfibaro.fibaro_scene import SceneModel
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ARMED,
|
ATTR_ARMED,
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
CONF_DEVICE_CLASS,
|
|
||||||
CONF_EXCLUDE,
|
|
||||||
CONF_ICON,
|
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_URL,
|
CONF_URL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
@ -31,22 +27,14 @@ from homeassistant.exceptions import (
|
|||||||
HomeAssistantError,
|
HomeAssistantError,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||||
from homeassistant.helpers.typing import ConfigType
|
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from .const import CONF_IMPORT_PLUGINS, DOMAIN
|
from .const import CONF_IMPORT_PLUGINS, DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_COLOR = "color"
|
|
||||||
CONF_DEVICE_CONFIG = "device_config"
|
|
||||||
CONF_DIMMING = "dimming"
|
|
||||||
CONF_GATEWAYS = "gateways"
|
|
||||||
CONF_PLUGINS = "plugins"
|
|
||||||
CONF_RESET_COLOR = "reset_color"
|
|
||||||
CONF_WHITE_VALUE = "white_value"
|
|
||||||
FIBARO_CONTROLLER = "fibaro_controller"
|
FIBARO_CONTROLLER = "fibaro_controller"
|
||||||
FIBARO_DEVICES = "fibaro_devices"
|
FIBARO_DEVICES = "fibaro_devices"
|
||||||
PLATFORMS = [
|
PLATFORMS = [
|
||||||
@ -86,45 +74,6 @@ FIBARO_TYPEMAP = {
|
|||||||
"com.fibaro.accelerometer": Platform.BINARY_SENSOR,
|
"com.fibaro.accelerometer": Platform.BINARY_SENSOR,
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Optional(CONF_DIMMING): cv.boolean,
|
|
||||||
vol.Optional(CONF_COLOR): cv.boolean,
|
|
||||||
vol.Optional(CONF_WHITE_VALUE): cv.boolean,
|
|
||||||
vol.Optional(CONF_RESET_COLOR): cv.boolean,
|
|
||||||
vol.Optional(CONF_DEVICE_CLASS): cv.string,
|
|
||||||
vol.Optional(CONF_ICON): cv.string,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
FIBARO_ID_LIST_SCHEMA = vol.Schema([cv.string])
|
|
||||||
|
|
||||||
GATEWAY_CONFIG = vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
|
||||||
vol.Required(CONF_URL): cv.url,
|
|
||||||
vol.Optional(CONF_PLUGINS, default=False): cv.boolean,
|
|
||||||
vol.Optional(CONF_EXCLUDE, default=[]): FIBARO_ID_LIST_SCHEMA,
|
|
||||||
vol.Optional(CONF_DEVICE_CONFIG, default={}): vol.Schema(
|
|
||||||
{cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}
|
|
||||||
),
|
|
||||||
},
|
|
||||||
extra=vol.ALLOW_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
|
||||||
vol.All(
|
|
||||||
cv.deprecated(DOMAIN),
|
|
||||||
{
|
|
||||||
DOMAIN: vol.Schema(
|
|
||||||
{vol.Required(CONF_GATEWAYS): vol.All(cv.ensure_list, [GATEWAY_CONFIG])}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
),
|
|
||||||
extra=vol.ALLOW_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FibaroController:
|
class FibaroController:
|
||||||
"""Initiate Fibaro Controller Class."""
|
"""Initiate Fibaro Controller Class."""
|
||||||
@ -413,37 +362,6 @@ class FibaroController:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
|
|
||||||
"""Migrate configuration from configuration.yaml."""
|
|
||||||
if DOMAIN not in base_config:
|
|
||||||
return True
|
|
||||||
gateways = base_config[DOMAIN][CONF_GATEWAYS]
|
|
||||||
if gateways is None:
|
|
||||||
return True
|
|
||||||
|
|
||||||
# check if already configured
|
|
||||||
if hass.config_entries.async_entries(DOMAIN):
|
|
||||||
return True
|
|
||||||
|
|
||||||
for gateway in gateways:
|
|
||||||
# prepare new config based on configuration.yaml
|
|
||||||
conf = {
|
|
||||||
CONF_URL: gateway[CONF_URL],
|
|
||||||
CONF_USERNAME: gateway[CONF_USERNAME],
|
|
||||||
CONF_PASSWORD: gateway[CONF_PASSWORD],
|
|
||||||
CONF_IMPORT_PLUGINS: gateway[CONF_PLUGINS],
|
|
||||||
}
|
|
||||||
|
|
||||||
# import into config flow based configuration
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def _init_controller(data: Mapping[str, Any]) -> FibaroController:
|
def _init_controller(data: Mapping[str, Any]) -> FibaroController:
|
||||||
"""Validate the user input allows us to connect to fibaro."""
|
"""Validate the user input allows us to connect to fibaro."""
|
||||||
controller = FibaroController(data)
|
controller = FibaroController(data)
|
||||||
|
@ -12,7 +12,6 @@ from homeassistant import config_entries
|
|||||||
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.typing import ConfigType
|
|
||||||
|
|
||||||
from . import FibaroAuthFailed, FibaroConnectFailed, FibaroController
|
from . import FibaroAuthFailed, FibaroConnectFailed, FibaroController
|
||||||
from .const import CONF_IMPORT_PLUGINS, DOMAIN
|
from .const import CONF_IMPORT_PLUGINS, DOMAIN
|
||||||
@ -98,10 +97,6 @@ class FibaroConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_import(self, import_config: ConfigType | None) -> FlowResult:
|
|
||||||
"""Import a config entry."""
|
|
||||||
return await self.async_step_user(import_config)
|
|
||||||
|
|
||||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||||
"""Handle reauthentication."""
|
"""Handle reauthentication."""
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||||
|
@ -211,35 +211,6 @@ async def test_config_flow_user_initiated_unknown_failure_2(
|
|||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
async def test_config_flow_import(hass: HomeAssistant) -> None:
|
|
||||||
"""Test for importing config from configuration.yaml."""
|
|
||||||
with patch(
|
|
||||||
"homeassistant.components.fibaro.FibaroClient.connect", return_value=True
|
|
||||||
), patch(
|
|
||||||
"homeassistant.components.fibaro.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
|
||||||
data={
|
|
||||||
CONF_URL: TEST_URL,
|
|
||||||
CONF_USERNAME: TEST_USERNAME,
|
|
||||||
CONF_PASSWORD: TEST_PASSWORD,
|
|
||||||
CONF_IMPORT_PLUGINS: False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
|
||||||
assert result["title"] == TEST_NAME
|
|
||||||
assert result["data"] == {
|
|
||||||
CONF_URL: TEST_URL,
|
|
||||||
CONF_USERNAME: TEST_USERNAME,
|
|
||||||
CONF_PASSWORD: TEST_PASSWORD,
|
|
||||||
CONF_IMPORT_PLUGINS: False,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async def test_reauth_success(hass: HomeAssistant) -> None:
|
async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||||
"""Successful reauth flow initialized by the user."""
|
"""Successful reauth flow initialized by the user."""
|
||||||
mock_config = MockConfigEntry(
|
mock_config = MockConfigEntry(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user