Remove previously deprecated ISY994 YAML support (#91575)
This commit is contained in:
parent
8d201b205f
commit
ef7e3e27ba
4 changed files with 3 additions and 232 deletions
|
@ -25,19 +25,15 @@ from homeassistant.helpers import aiohttp_client, config_validation as cv
|
|||
import homeassistant.helpers.device_registry as dr
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
_LOGGER,
|
||||
CONF_IGNORE_STRING,
|
||||
CONF_NETWORK,
|
||||
CONF_RESTORE_LIGHT_STATE,
|
||||
CONF_SENSOR_STRING,
|
||||
CONF_TLS_VER,
|
||||
CONF_VAR_SENSOR_STRING,
|
||||
DEFAULT_IGNORE_STRING,
|
||||
DEFAULT_RESTORE_LIGHT_STATE,
|
||||
DEFAULT_SENSOR_STRING,
|
||||
DEFAULT_VAR_SENSOR_STRING,
|
||||
DOMAIN,
|
||||
|
@ -55,90 +51,16 @@ from .services import async_setup_services, async_unload_services
|
|||
from .util import _async_cleanup_registry_entries
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
cv.deprecated(DOMAIN),
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.url,
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_TLS_VER): vol.Coerce(float),
|
||||
vol.Optional(
|
||||
CONF_IGNORE_STRING, default=DEFAULT_IGNORE_STRING
|
||||
): cv.string,
|
||||
vol.Optional(
|
||||
CONF_SENSOR_STRING, default=DEFAULT_SENSOR_STRING
|
||||
): cv.string,
|
||||
vol.Optional(
|
||||
CONF_VAR_SENSOR_STRING, default=DEFAULT_VAR_SENSOR_STRING
|
||||
): cv.string,
|
||||
vol.Required(
|
||||
CONF_RESTORE_LIGHT_STATE, default=DEFAULT_RESTORE_LIGHT_STATE
|
||||
): bool,
|
||||
},
|
||||
)
|
||||
},
|
||||
),
|
||||
cv.deprecated(DOMAIN),
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the isy994 integration from YAML."""
|
||||
isy_config: ConfigType | None = config.get(DOMAIN)
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
if not isy_config:
|
||||
return True
|
||||
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_yaml",
|
||||
breaks_in_ha_version="2023.5.0",
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_yaml",
|
||||
)
|
||||
|
||||
# Only import if we haven't before.
|
||||
config_entry = _async_find_matching_config_entry(hass)
|
||||
if not config_entry:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=dict(isy_config),
|
||||
)
|
||||
)
|
||||
return True
|
||||
|
||||
# Update the entry based on the YAML configuration, in case it changed.
|
||||
hass.config_entries.async_update_entry(config_entry, data=dict(isy_config))
|
||||
return True
|
||||
|
||||
|
||||
@callback
|
||||
def _async_find_matching_config_entry(
|
||||
hass: HomeAssistant,
|
||||
) -> config_entries.ConfigEntry | None:
|
||||
for entry in hass.config_entries.async_entries(DOMAIN):
|
||||
if entry.source == config_entries.SOURCE_IMPORT:
|
||||
return entry
|
||||
return None
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: config_entries.ConfigEntry
|
||||
) -> bool:
|
||||
"""Set up the ISY 994 integration."""
|
||||
# As there currently is no way to import options from yaml
|
||||
# when setting up a config entry, we fallback to adding
|
||||
# the options to the config entry and pull them out here if
|
||||
# they are missing from the options
|
||||
_async_import_options_from_data_if_missing(hass, entry)
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
isy_data = hass.data[DOMAIN][entry.entry_id] = IsyData()
|
||||
|
||||
isy_config = entry.data
|
||||
|
@ -268,25 +190,6 @@ async def _async_update_listener(
|
|||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
|
||||
@callback
|
||||
def _async_import_options_from_data_if_missing(
|
||||
hass: HomeAssistant, entry: config_entries.ConfigEntry
|
||||
) -> None:
|
||||
options = dict(entry.options)
|
||||
modified = False
|
||||
for importable_option in (
|
||||
CONF_IGNORE_STRING,
|
||||
CONF_SENSOR_STRING,
|
||||
CONF_RESTORE_LIGHT_STATE,
|
||||
):
|
||||
if importable_option not in entry.options and importable_option in entry.data:
|
||||
options[importable_option] = entry.data[importable_option]
|
||||
modified = True
|
||||
|
||||
if modified:
|
||||
hass.config_entries.async_update_entry(entry, options=options)
|
||||
|
||||
|
||||
@callback
|
||||
def _async_get_or_create_isy_device_in_registry(
|
||||
hass: HomeAssistant, entry: config_entries.ConfigEntry, isy: ISY
|
||||
|
|
|
@ -168,10 +168,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
"""Handle import."""
|
||||
return await self.async_step_user(user_input)
|
||||
|
||||
async def _async_set_unique_id_or_update(
|
||||
self, isy_mac: str, ip_address: str, port: int | None
|
||||
) -> None:
|
||||
|
|
|
@ -53,22 +53,5 @@
|
|||
"last_heartbeat": "Last Heartbeat Time",
|
||||
"websocket_status": "Event Socket Status"
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"deprecated_service": {
|
||||
"title": "The {deprecated_service} service will be removed",
|
||||
"fix_flow": {
|
||||
"step": {
|
||||
"confirm": {
|
||||
"title": "The {deprecated_service} service will be removed",
|
||||
"description": "Update any automations or scripts that use this service to instead use the `{alternate_service}` service with a target entity ID of `{alternate_target}`."
|
||||
},
|
||||
"deprecated_yaml": {
|
||||
"title": "The ISY/IoX YAML configuration is being removed",
|
||||
"description": "Configuring Universal Devices ISY/IoX using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the `isy994` YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue