diff --git a/custom_components/audiconnect/config_flow.py b/custom_components/audiconnect/config_flow.py index 2c174267..eb1ffa1d 100644 --- a/custom_components/audiconnect/config_flow.py +++ b/custom_components/audiconnect/config_flow.py @@ -20,6 +20,7 @@ MIN_UPDATE_INTERVAL, CONF_SCAN_INITIAL, CONF_SCAN_ACTIVE, + REGIONS, ) _LOGGER = logging.getLogger(__name__) @@ -52,7 +53,7 @@ async def async_step_user(self, user_input=None): self._username = user_input[CONF_USERNAME] self._password = user_input[CONF_PASSWORD] self._spin = user_input.get(CONF_SPIN) - self._region = user_input.get(CONF_REGION) + self._region = REGIONS[user_input.get(CONF_REGION)] self._scan_interval = user_input[CONF_SCAN_INTERVAL] try: @@ -94,7 +95,7 @@ async def async_step_user(self, user_input=None): data_schema[vol.Required(CONF_USERNAME, default=self._username)] = str data_schema[vol.Required(CONF_PASSWORD, default=self._password)] = str data_schema[vol.Optional(CONF_SPIN, default=self._spin)] = str - data_schema[vol.Optional(CONF_REGION, default=self._region)] = str + data_schema[vol.Required(CONF_REGION, default=self._region)] = vol.In(REGIONS) data_schema[ vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_UPDATE_INTERVAL) ] = int @@ -116,7 +117,7 @@ async def async_step_import(self, user_input): region = "DE" if user_input.get(CONF_REGION): - region = user_input.get(CONF_REGION) + region = REGIONS[user_input.get(CONF_REGION)] scan_interval = DEFAULT_UPDATE_INTERVAL diff --git a/custom_components/audiconnect/const.py b/custom_components/audiconnect/const.py index 3a68d52c..08485784 100644 --- a/custom_components/audiconnect/const.py +++ b/custom_components/audiconnect/const.py @@ -77,3 +77,15 @@ "device_tracker": "device_tracker", "switch": "switch", } + +REGION_EUROPE: str = "DE" +REGION_CANADA: str = "CA" +REGION_USA: str = "US" +REGION_CHINA: str = "CN" + +REGIONS = { + 1: REGION_EUROPE, + 2: REGION_CANADA, + 3: REGION_USA, + 4: REGION_CHINA, +} diff --git a/readme.md b/readme.md index 88bfc445..64610499 100644 --- a/readme.md +++ b/readme.md @@ -44,7 +44,7 @@ Configuration is done through the Home Assistant UI. To add the integration, go to **Settings ➤ Devices & Services ➤ Integrations**, click **➕ Add Integration**, and search for "Audi Connect". -![Configuration](ha_config.png) +![image](https://github.com/user-attachments/assets/facff84e-f40f-4090-9e44-80f698385426) ### Configuration Variables @@ -62,7 +62,7 @@ To add the integration, go to **Settings ➤ Devices & Services ➤ Integrations **region** -- (string)(Optional) The region where your Audi Connect account is registered. +- (string)(Required) The region where your Audi Connect account is registered. - 'DE' for Europe (or leave unset) - 'US' for United States of America - 'CA' for Canada