Add error handling to input_select integration (#93940)

This commit is contained in:
j4n-e4t 2023-06-05 19:53:24 +02:00 committed by GitHub
parent e2c2262719
commit 28f6062bab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 18 deletions

View file

@ -302,12 +302,9 @@ class InputSelect(collection.CollectionEntity, SelectEntity, RestoreEntity):
async def async_select_option(self, option: str) -> None:
"""Select new option."""
if option not in self.options:
_LOGGER.warning(
"Invalid option: %s (possible options: %s)",
option,
", ".join(self.options),
raise HomeAssistantError(
f"Invalid option: {option} (possible options: {', '.join(self.options)})"
)
return
self._attr_current_option = option
self.async_write_ha_state()