mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Handle non documented options at Home Connect select entities (#140608)
* Allow non documented options at select entities * Don't allow undocumented options
This commit is contained in:
parent
9d8dbfbf3f
commit
28cad1d085
@ -415,6 +415,7 @@ class HomeConnectSelectEntity(HomeConnectEntity, SelectEntity):
|
||||
"""Select setting class for Home Connect."""
|
||||
|
||||
entity_description: HomeConnectSelectEntityDescription
|
||||
_original_option_keys: set[str | None]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -423,6 +424,7 @@ class HomeConnectSelectEntity(HomeConnectEntity, SelectEntity):
|
||||
desc: HomeConnectSelectEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the entity."""
|
||||
self._original_option_keys = set(desc.values_translation_key)
|
||||
super().__init__(
|
||||
coordinator,
|
||||
appliance,
|
||||
@ -477,10 +479,12 @@ class HomeConnectSelectEntity(HomeConnectEntity, SelectEntity):
|
||||
)
|
||||
|
||||
if setting and setting.constraints and setting.constraints.allowed_values:
|
||||
self._original_option_keys = set(setting.constraints.allowed_values)
|
||||
self._attr_options = [
|
||||
self.entity_description.values_translation_key[option]
|
||||
for option in setting.constraints.allowed_values
|
||||
if option in self.entity_description.values_translation_key
|
||||
for option in self._original_option_keys
|
||||
if option is not None
|
||||
and option in self.entity_description.values_translation_key
|
||||
]
|
||||
|
||||
|
||||
@ -497,7 +501,7 @@ class HomeConnectSelectOptionEntity(HomeConnectOptionEntity, SelectEntity):
|
||||
desc: HomeConnectSelectEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the entity."""
|
||||
self._original_option_keys = set(desc.values_translation_key.keys())
|
||||
self._original_option_keys = set(desc.values_translation_key)
|
||||
super().__init__(
|
||||
coordinator,
|
||||
appliance,
|
||||
@ -530,5 +534,5 @@ class HomeConnectSelectOptionEntity(HomeConnectOptionEntity, SelectEntity):
|
||||
self.entity_description.values_translation_key[option]
|
||||
for option in self._original_option_keys
|
||||
if option is not None
|
||||
and option in self.entity_description.values_translation_key
|
||||
]
|
||||
self.__dict__.pop("options", None)
|
||||
|
@ -522,9 +522,18 @@ async def test_select_functionality(
|
||||
(
|
||||
"select.hood_ambient_light_color",
|
||||
SettingKey.BSH_COMMON_AMBIENT_LIGHT_COLOR,
|
||||
[f"BSH.Common.EnumType.AmbientLightColor.Color{i}" for i in range(50)],
|
||||
[f"BSH.Common.EnumType.AmbientLightColor.Color{i}" for i in range(1, 50)],
|
||||
{str(i) for i in range(1, 50)},
|
||||
),
|
||||
(
|
||||
"select.hood_ambient_light_color",
|
||||
SettingKey.BSH_COMMON_AMBIENT_LIGHT_COLOR,
|
||||
[
|
||||
"A.Non.Documented.Option",
|
||||
"BSH.Common.EnumType.AmbientLightColor.Color42",
|
||||
],
|
||||
{"42"},
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_fetch_allowed_values(
|
||||
@ -813,6 +822,17 @@ async def test_select_entity_error(
|
||||
"laundry_care_washer_enum_type_temperature_ul_extra_hot",
|
||||
},
|
||||
),
|
||||
(
|
||||
"select.washer_temperature",
|
||||
OptionKey.LAUNDRY_CARE_WASHER_TEMPERATURE,
|
||||
[
|
||||
"A.Non.Documented.Option",
|
||||
"LaundryCare.Washer.EnumType.Temperature.UlWarm",
|
||||
],
|
||||
{
|
||||
"laundry_care_washer_enum_type_temperature_ul_warm",
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_options_functionality(
|
||||
|
Loading…
x
Reference in New Issue
Block a user