From 66f12d7dab9740be1e5b261ffea99d5e5d63c506 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis <jbouwh@users.noreply.github.com> Date: Tue, 24 Jan 2023 12:25:35 +0100 Subject: [PATCH] Add translations for shelly ble scanner options in option flow (#86218) * Add translations for shelly ble scanner options * Remove redundant labels * isort --- homeassistant/components/shelly/config_flow.py | 17 ++++++++--------- homeassistant/components/shelly/strings.json | 9 +++++++++ .../components/shelly/translations/en.json | 9 +++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/shelly/config_flow.py b/homeassistant/components/shelly/config_flow.py index 612e2be0a74..0979e6e036a 100644 --- a/homeassistant/components/shelly/config_flow.py +++ b/homeassistant/components/shelly/config_flow.py @@ -21,11 +21,7 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant, callback from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession -from homeassistant.helpers.selector import ( - SelectOptionDict, - SelectSelector, - SelectSelectorConfig, -) +from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig from .const import ( BLE_MIN_VERSION, @@ -53,9 +49,9 @@ HOST_SCHEMA: Final = vol.Schema({vol.Required(CONF_HOST): str}) BLE_SCANNER_OPTIONS = [ - SelectOptionDict(value=BLEScannerMode.DISABLED, label="Disabled"), - SelectOptionDict(value=BLEScannerMode.ACTIVE, label="Active"), - SelectOptionDict(value=BLEScannerMode.PASSIVE, label="Passive"), + BLEScannerMode.DISABLED, + BLEScannerMode.ACTIVE, + BLEScannerMode.PASSIVE, ] INTERNAL_WIFI_AP_IP = "192.168.33.1" @@ -403,7 +399,10 @@ class OptionsFlowHandler(OptionsFlow): CONF_BLE_SCANNER_MODE, BLEScannerMode.DISABLED ), ): SelectSelector( - SelectSelectorConfig(options=BLE_SCANNER_OPTIONS), + SelectSelectorConfig( + options=BLE_SCANNER_OPTIONS, + translation_key=CONF_BLE_SCANNER_MODE, + ), ), } ), diff --git a/homeassistant/components/shelly/strings.json b/homeassistant/components/shelly/strings.json index 9f67ed0181d..1f05364ca3e 100644 --- a/homeassistant/components/shelly/strings.json +++ b/homeassistant/components/shelly/strings.json @@ -71,5 +71,14 @@ "abort": { "ble_unsupported": "Bluetooth support requires firmware version {ble_min_version} or newer." } + }, + "selector": { + "ble_scanner_mode": { + "options": { + "disabled": "Disabled", + "active": "Active", + "passive": "Passive" + } + } } } diff --git a/homeassistant/components/shelly/translations/en.json b/homeassistant/components/shelly/translations/en.json index d6e41c0d118..302cb71f482 100644 --- a/homeassistant/components/shelly/translations/en.json +++ b/homeassistant/components/shelly/translations/en.json @@ -71,5 +71,14 @@ "description": "Bluetooth scanning can be active or passive. With active, the Shelly requests data from nearby devices; with passive, the Shelly receives unsolicited data from nearby devices." } } + }, + "selector": { + "ble_scanner_mode": { + "options": { + "disabled": "Disabled", + "active": "Active", + "passive": "Passive" + } + } } } \ No newline at end of file -- GitLab