Rename const maps in Whirlpool (#143409)

This commit is contained in:
Abílio Costa 2025-04-29 19:39:29 +01:00 committed by GitHub
parent ad3fd151aa
commit 92da640d4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View File

@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_BRAND, CONF_BRANDS_MAP, CONF_REGIONS_MAP, DOMAIN from .const import BRANDS_CONF_MAP, CONF_BRAND, DOMAIN, REGIONS_CONF_MAP
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -25,8 +25,8 @@ type WhirlpoolConfigEntry = ConfigEntry[AppliancesManager]
async def async_setup_entry(hass: HomeAssistant, entry: WhirlpoolConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: WhirlpoolConfigEntry) -> bool:
"""Set up Whirlpool Sixth Sense from a config entry.""" """Set up Whirlpool Sixth Sense from a config entry."""
session = async_get_clientsession(hass) session = async_get_clientsession(hass)
region = CONF_REGIONS_MAP[entry.data.get(CONF_REGION, "EU")] region = REGIONS_CONF_MAP[entry.data.get(CONF_REGION, "EU")]
brand = CONF_BRANDS_MAP[entry.data.get(CONF_BRAND, "Whirlpool")] brand = BRANDS_CONF_MAP[entry.data.get(CONF_BRAND, "Whirlpool")]
backend_selector = BackendSelector(brand, region) backend_selector = BackendSelector(brand, region)
auth = Auth( auth = Auth(

View File

@ -17,7 +17,7 @@ from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import CONF_BRAND, CONF_BRANDS_MAP, CONF_REGIONS_MAP, DOMAIN from .const import BRANDS_CONF_MAP, CONF_BRAND, DOMAIN, REGIONS_CONF_MAP
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -26,15 +26,15 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
{ {
vol.Required(CONF_USERNAME): str, vol.Required(CONF_USERNAME): str,
vol.Required(CONF_PASSWORD): str, vol.Required(CONF_PASSWORD): str,
vol.Required(CONF_REGION): vol.In(list(CONF_REGIONS_MAP)), vol.Required(CONF_REGION): vol.In(list(REGIONS_CONF_MAP)),
vol.Required(CONF_BRAND): vol.In(list(CONF_BRANDS_MAP)), vol.Required(CONF_BRAND): vol.In(list(BRANDS_CONF_MAP)),
} }
) )
REAUTH_SCHEMA = vol.Schema( REAUTH_SCHEMA = vol.Schema(
{ {
vol.Required(CONF_PASSWORD): str, vol.Required(CONF_PASSWORD): str,
vol.Required(CONF_BRAND): vol.In(list(CONF_BRANDS_MAP)), vol.Required(CONF_BRAND): vol.In(list(BRANDS_CONF_MAP)),
} }
) )
@ -48,8 +48,8 @@ async def authenticate(
Returns the error translation key if authentication fails, or None on success. Returns the error translation key if authentication fails, or None on success.
""" """
session = async_get_clientsession(hass) session = async_get_clientsession(hass)
region = CONF_REGIONS_MAP[data[CONF_REGION]] region = REGIONS_CONF_MAP[data[CONF_REGION]]
brand = CONF_BRANDS_MAP[data[CONF_BRAND]] brand = BRANDS_CONF_MAP[data[CONF_BRAND]]
backend_selector = BackendSelector(brand, region) backend_selector = BackendSelector(brand, region)
auth = Auth(backend_selector, data[CONF_USERNAME], data[CONF_PASSWORD], session) auth = Auth(backend_selector, data[CONF_USERNAME], data[CONF_PASSWORD], session)

View File

@ -5,12 +5,12 @@ from whirlpool.backendselector import Brand, Region
DOMAIN = "whirlpool" DOMAIN = "whirlpool"
CONF_BRAND = "brand" CONF_BRAND = "brand"
CONF_REGIONS_MAP = { REGIONS_CONF_MAP = {
"EU": Region.EU, "EU": Region.EU,
"US": Region.US, "US": Region.US,
} }
CONF_BRANDS_MAP = { BRANDS_CONF_MAP = {
"Whirlpool": Brand.Whirlpool, "Whirlpool": Brand.Whirlpool,
"Maytag": Brand.Maytag, "Maytag": Brand.Maytag,
"KitchenAid": Brand.KitchenAid, "KitchenAid": Brand.KitchenAid,