Use server name as entry title in Jellyfin (#79965)

This commit is contained in:
Chris Talkington 2022-10-09 23:50:05 -05:00 committed by GitHub
parent ef719cf7ef
commit 84acb416b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1939 additions and 44 deletions

View file

@ -54,7 +54,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
client = create_client(device_id=self.client_device_id)
try:
userid = await validate_input(self.hass, user_input, client)
user_id, connect_result = await validate_input(
self.hass, user_input, client
)
except CannotConnect:
errors["base"] = "cannot_connect"
except InvalidAuth:
@ -63,11 +65,18 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors["base"] = "unknown"
_LOGGER.exception(ex)
else:
await self.async_set_unique_id(userid)
entry_title = user_input[CONF_URL]
server_info: dict[str, Any] = connect_result["Servers"][0]
if server_name := server_info.get("Name"):
entry_title = server_name
await self.async_set_unique_id(user_id)
self._abort_if_unique_id_configured()
return self.async_create_entry(
title=user_input[CONF_URL],
title=entry_title,
data={CONF_CLIENT_DEVICE_ID: self.client_device_id, **user_input},
)