diff --git a/homeassistant/components/telegram_bot/config_flow.py b/homeassistant/components/telegram_bot/config_flow.py index 5609a621da30..6d5422b8368b 100644 --- a/homeassistant/components/telegram_bot/config_flow.py +++ b/homeassistant/components/telegram_bot/config_flow.py @@ -53,7 +53,7 @@ from .const import ( PLATFORM_BROADCAST, PLATFORM_POLLING, PLATFORM_WEBHOOKS, - SECTION_ADVANCED_SETTINGS, + SECTION_ADDITIONAL_SETTINGS, SUBENTRY_TYPE_ALLOWED_CHAT_IDS, ) @@ -65,7 +65,7 @@ DESCRIPTION_PLACEHOLDERS: dict[str, str] = { "id_bot_username": "@id_bot", "id_bot_url": "https://t.me/id_bot", "socks_url": "socks5://username:password@proxy_ip:proxy_port", - # used in advanced settings section + # used in additional settings section "default_api_endpoint": DEFAULT_API_ENDPOINT, } @@ -87,7 +87,7 @@ STEP_USER_DATA_SCHEMA: vol.Schema = vol.Schema( autocomplete="current-password", ) ), - vol.Required(SECTION_ADVANCED_SETTINGS): section( + vol.Required(SECTION_ADDITIONAL_SETTINGS): section( vol.Schema( { vol.Required( @@ -117,7 +117,7 @@ STEP_RECONFIGURE_USER_DATA_SCHEMA: vol.Schema = vol.Schema( translation_key="platforms", ) ), - vol.Required(SECTION_ADVANCED_SETTINGS): section( + vol.Required(SECTION_ADDITIONAL_SETTINGS): section( vol.Schema( { vol.Required( @@ -241,10 +241,10 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN): # validate connection to Telegram API errors: dict[str, str] = {} - user_input[CONF_API_ENDPOINT] = user_input[SECTION_ADVANCED_SETTINGS][ + user_input[CONF_API_ENDPOINT] = user_input[SECTION_ADDITIONAL_SETTINGS][ CONF_API_ENDPOINT ] - user_input[CONF_PROXY_URL] = user_input[SECTION_ADVANCED_SETTINGS].get( + user_input[CONF_PROXY_URL] = user_input[SECTION_ADDITIONAL_SETTINGS].get( CONF_PROXY_URL ) bot_name = await self._validate_bot( @@ -270,9 +270,7 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN): CONF_PLATFORM: user_input[CONF_PLATFORM], CONF_API_ENDPOINT: user_input[CONF_API_ENDPOINT], CONF_API_KEY: user_input[CONF_API_KEY], - CONF_PROXY_URL: user_input[SECTION_ADVANCED_SETTINGS].get( - CONF_PROXY_URL - ), + CONF_PROXY_URL: user_input[CONF_PROXY_URL], }, options={ATTR_PARSER: PARSER_MD}, description_placeholders=description_placeholders, @@ -383,10 +381,10 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN): data={ CONF_PLATFORM: self._step_user_data[CONF_PLATFORM], CONF_API_KEY: self._step_user_data[CONF_API_KEY], - CONF_API_ENDPOINT: self._step_user_data[SECTION_ADVANCED_SETTINGS][ + CONF_API_ENDPOINT: self._step_user_data[SECTION_ADDITIONAL_SETTINGS][ CONF_API_ENDPOINT ], - CONF_PROXY_URL: self._step_user_data[SECTION_ADVANCED_SETTINGS].get( + CONF_PROXY_URL: self._step_user_data[SECTION_ADDITIONAL_SETTINGS].get( CONF_PROXY_URL ), CONF_URL: user_input.get(CONF_URL), @@ -461,7 +459,7 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN): STEP_RECONFIGURE_USER_DATA_SCHEMA, { **self._get_reconfigure_entry().data, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: self._get_reconfigure_entry().data[ CONF_API_ENDPOINT ], @@ -473,11 +471,11 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN): ), description_placeholders=DESCRIPTION_PLACEHOLDERS, ) - user_input[CONF_PROXY_URL] = user_input[SECTION_ADVANCED_SETTINGS].get( + user_input[CONF_PROXY_URL] = user_input[SECTION_ADDITIONAL_SETTINGS].get( CONF_PROXY_URL ) - user_input[CONF_API_ENDPOINT] = user_input[SECTION_ADVANCED_SETTINGS][ + user_input[CONF_API_ENDPOINT] = user_input[SECTION_ADDITIONAL_SETTINGS][ CONF_API_ENDPOINT ] @@ -528,7 +526,7 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN): STEP_RECONFIGURE_USER_DATA_SCHEMA, { **user_input, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: user_input[CONF_API_ENDPOINT], CONF_PROXY_URL: user_input.get(CONF_PROXY_URL), }, diff --git a/homeassistant/components/telegram_bot/const.py b/homeassistant/components/telegram_bot/const.py index 69606b2fd44c..fb2de2c5d934 100644 --- a/homeassistant/components/telegram_bot/const.py +++ b/homeassistant/components/telegram_bot/const.py @@ -7,7 +7,7 @@ DOMAIN = "telegram_bot" PLATFORM_BROADCAST = "broadcast" PLATFORM_POLLING = "polling" PLATFORM_WEBHOOKS = "webhooks" -SECTION_ADVANCED_SETTINGS = "advanced_settings" +SECTION_ADDITIONAL_SETTINGS = "additional_settings" SUBENTRY_TYPE_ALLOWED_CHAT_IDS = "allowed_chat_ids" CONF_ALLOWED_CHAT_IDS = "allowed_chat_ids" diff --git a/homeassistant/components/telegram_bot/strings.json b/homeassistant/components/telegram_bot/strings.json index 98a91a37d3e5..67a5cfa08224 100644 --- a/homeassistant/components/telegram_bot/strings.json +++ b/homeassistant/components/telegram_bot/strings.json @@ -33,16 +33,16 @@ }, "description": "Reconfigure Telegram bot", "sections": { - "advanced_settings": { + "additional_settings": { "data": { - "api_endpoint": "[%key:component::telegram_bot::config::step::user::sections::advanced_settings::data::api_endpoint%]", - "proxy_url": "[%key:component::telegram_bot::config::step::user::sections::advanced_settings::data::proxy_url%]" + "api_endpoint": "[%key:component::telegram_bot::config::step::user::sections::additional_settings::data::api_endpoint%]", + "proxy_url": "[%key:component::telegram_bot::config::step::user::sections::additional_settings::data::proxy_url%]" }, "data_description": { - "api_endpoint": "[%key:component::telegram_bot::config::step::user::sections::advanced_settings::data_description::api_endpoint%]", - "proxy_url": "[%key:component::telegram_bot::config::step::user::sections::advanced_settings::data_description::proxy_url%]" + "api_endpoint": "[%key:component::telegram_bot::config::step::user::sections::additional_settings::data_description::api_endpoint%]", + "proxy_url": "[%key:component::telegram_bot::config::step::user::sections::additional_settings::data_description::proxy_url%]" }, - "name": "[%key:component::telegram_bot::config::step::user::sections::advanced_settings::name%]" + "name": "[%key:component::telegram_bot::config::step::user::sections::additional_settings::name%]" } }, "title": "Telegram bot setup" @@ -58,7 +58,7 @@ }, "description": "To create a Telegram bot, follow these steps:\n\n1. Open Telegram and start a chat with [{botfather_username}]({botfather_url}).\n1. Send the command `/newbot`.\n1. Follow the instructions to create your bot and get your API token.", "sections": { - "advanced_settings": { + "additional_settings": { "data": { "api_endpoint": "API endpoint", "proxy_url": "Proxy URL" diff --git a/tests/components/telegram_bot/test_config_flow.py b/tests/components/telegram_bot/test_config_flow.py index 3da3336c35e2..3000adda996a 100644 --- a/tests/components/telegram_bot/test_config_flow.py +++ b/tests/components/telegram_bot/test_config_flow.py @@ -20,7 +20,7 @@ from homeassistant.components.telegram_bot.const import ( PARSER_PLAIN_TEXT, PLATFORM_BROADCAST, PLATFORM_WEBHOOKS, - SECTION_ADVANCED_SETTINGS, + SECTION_ADDITIONAL_SETTINGS, SUBENTRY_TYPE_ALLOWED_CHAT_IDS, ) from homeassistant.components.telegram_bot.webhooks import TELEGRAM_WEBHOOK_URL @@ -100,7 +100,7 @@ async def test_reconfigure_flow_broadcast( result["flow_id"], { CONF_PLATFORM: PLATFORM_BROADCAST, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_PROXY_URL: "invalid", }, }, @@ -117,7 +117,7 @@ async def test_reconfigure_flow_broadcast( result["flow_id"], { CONF_PLATFORM: PLATFORM_BROADCAST, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_PROXY_URL: "https://test", }, }, @@ -155,7 +155,7 @@ async def test_reconfigure_flow_webhooks( result["flow_id"], { CONF_PLATFORM: PLATFORM_WEBHOOKS, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: DEFAULT_API_ENDPOINT, CONF_PROXY_URL: "https://test", }, @@ -271,7 +271,7 @@ async def test_reconfigure_flow_logout_failed( result["flow_id"], { CONF_PLATFORM: PLATFORM_BROADCAST, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: "http://mock1", }, }, @@ -289,7 +289,7 @@ async def test_reconfigure_flow_logout_failed( result["flow_id"], { CONF_PLATFORM: PLATFORM_BROADCAST, - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: "http://mock2", }, }, @@ -327,7 +327,7 @@ async def test_create_entry( { CONF_PLATFORM: PLATFORM_WEBHOOKS, CONF_API_KEY: "mock api key", - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_PROXY_URL: "invalid", }, }, @@ -350,7 +350,7 @@ async def test_create_entry( { CONF_PLATFORM: PLATFORM_WEBHOOKS, CONF_API_KEY: "mock api key", - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_PROXY_URL: "https://proxy", }, }, @@ -374,7 +374,7 @@ async def test_create_entry( { CONF_PLATFORM: PLATFORM_WEBHOOKS, CONF_API_KEY: "mock api key", - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_PROXY_URL: "https://proxy", }, }, @@ -446,7 +446,7 @@ async def test_create_webhook_entry( { CONF_PLATFORM: PLATFORM_WEBHOOKS, CONF_API_KEY: "mock api key", - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: api_endpoint, }, }, @@ -774,7 +774,7 @@ async def test_duplicate_entry(hass: HomeAssistant) -> None: data = { CONF_PLATFORM: PLATFORM_BROADCAST, CONF_API_KEY: "mock api key", - SECTION_ADVANCED_SETTINGS: { + SECTION_ADDITIONAL_SETTINGS: { CONF_API_ENDPOINT: "http://mock_api_endpoint", }, } diff --git a/tests/components/telegram_bot/test_telegram_bot.py b/tests/components/telegram_bot/test_telegram_bot.py index 6d9d39e9fb3a..a4592826d752 100644 --- a/tests/components/telegram_bot/test_telegram_bot.py +++ b/tests/components/telegram_bot/test_telegram_bot.py @@ -67,7 +67,7 @@ from homeassistant.components.telegram_bot.const import ( PARSER_MD2, PARSER_PLAIN_TEXT, PLATFORM_BROADCAST, - SECTION_ADVANCED_SETTINGS, + SECTION_ADDITIONAL_SETTINGS, SERVICE_ANSWER_CALLBACK_QUERY, SERVICE_DELETE_MESSAGE, SERVICE_EDIT_CAPTION, @@ -1093,7 +1093,7 @@ async def test_send_message_no_chat_id_error( data={ CONF_PLATFORM: PLATFORM_BROADCAST, CONF_API_KEY: "mock api key", - SECTION_ADVANCED_SETTINGS: {}, + SECTION_ADDITIONAL_SETTINGS: {}, }, options={ATTR_PARSER: PARSER_PLAIN_TEXT}, )