Remove name key from transimssion services (#83974)

This commit is contained in:
Rami Mosleh 2022-12-19 14:38:54 +02:00 committed by GitHub
parent bb3feceb57
commit 099a653bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 62 deletions

View File

@ -14,7 +14,6 @@ from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import (
CONF_HOST,
CONF_ID,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_SCAN_INTERVAL,
@ -26,7 +25,6 @@ from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv, selector
from homeassistant.helpers.dispatcher import dispatcher_send
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
from .const import (
ATTR_DELETE_DATA,
@ -56,13 +54,11 @@ _LOGGER = logging.getLogger(__name__)
SERVICE_BASE_SCHEMA = vol.Schema(
{
vol.Exclusive(CONF_ENTRY_ID, "identifier"): selector.ConfigEntrySelector(),
vol.Exclusive(CONF_NAME, "identifier"): selector.TextSelector(),
}
)
SERVICE_ADD_TORRENT_SCHEMA = vol.All(
SERVICE_BASE_SCHEMA.extend({vol.Required(ATTR_TORRENT): cv.string}),
cv.has_at_least_one_key(CONF_ENTRY_ID, CONF_NAME),
)
@ -72,13 +68,11 @@ SERVICE_REMOVE_TORRENT_SCHEMA = vol.All(
vol.Required(CONF_ID): cv.positive_int,
vol.Optional(ATTR_DELETE_DATA, default=DEFAULT_DELETE_DATA): cv.boolean,
}
),
cv.has_at_least_one_key(CONF_ENTRY_ID, CONF_NAME),
)
)
SERVICE_START_TORRENT_SCHEMA = vol.All(
SERVICE_BASE_SCHEMA.extend({vol.Required(CONF_ID): cv.positive_int}),
cv.has_at_least_one_key(CONF_ENTRY_ID, CONF_NAME),
)
SERVICE_STOP_TORRENT_SCHEMA = vol.All(
@ -86,8 +80,7 @@ SERVICE_STOP_TORRENT_SCHEMA = vol.All(
{
vol.Required(CONF_ID): cv.positive_int,
}
),
cv.has_at_least_one_key(CONF_ENTRY_ID, CONF_NAME),
)
)
CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
@ -165,27 +158,6 @@ def _get_client(hass: HomeAssistant, data: dict[str, Any]) -> TransmissionClient
):
return hass.data[DOMAIN][entry_id]
# to be removed once name key is removed
if CONF_NAME in data:
create_issue(
hass,
DOMAIN,
"deprecated_key",
breaks_in_ha_version="2023.1.0",
is_fixable=True,
is_persistent=True,
severity=IssueSeverity.WARNING,
translation_key="deprecated_key",
)
_LOGGER.warning(
'The "name" key in the Transmission services is deprecated and will be removed in "2023.1.0"; '
'use the "entry_id" key instead to identity which entry to call'
)
for entry in hass.config_entries.async_entries(DOMAIN):
if entry.data[CONF_NAME] == data[CONF_NAME]:
return hass.data[DOMAIN][entry.entry_id]
return None

View File

@ -8,12 +8,6 @@ add_torrent:
selector:
config_entry:
integration: transmission
name:
name: Name
description: Instance name as entered during entry config
example: Transmission
selector:
text:
torrent:
name: Torrent
description: URL, magnet link or Base64 encoded file.

View File

@ -40,18 +40,5 @@
}
}
}
},
"issues": {
"deprecated_key": {
"title": "The name key in Transmission services is being removed",
"fix_flow": {
"step": {
"confirm": {
"title": "The name key in Transmission services is being removed",
"description": "Update any automations or scripts that use this service and replace the name key with the entry_id key."
}
}
}
}
}
}

View File

@ -29,19 +29,6 @@
}
}
},
"issues": {
"deprecated_key": {
"fix_flow": {
"step": {
"confirm": {
"description": "Update any automations or scripts that use this service and replace the name key with the entry_id key.",
"title": "The name key in Transmission services is being removed"
}
}
},
"title": "The name key in Transmission services is being removed"
}
},
"options": {
"step": {
"init": {