Remove option and range checks in Rituals integration (#55222)

* Fix number

* Fix select
This commit is contained in:
Milan Meulemans 2021-08-26 08:37:27 +02:00 committed by GitHub
parent b45c985d58
commit e6d710c203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View File

@ -54,10 +54,8 @@ class DiffuserPerfumeAmount(DiffuserEntity, NumberEntity):
async def async_set_value(self, value: float) -> None:
"""Set the perfume amount."""
if value.is_integer() and MIN_PERFUME_AMOUNT <= value <= MAX_PERFUME_AMOUNT:
await self._diffuser.set_perfume_amount(int(value))
else:
if not value.is_integer():
raise ValueError(
f"Can't set the perfume amount to {value}. "
f"Perfume amount must be an integer between {self.min_value} and {self.max_value}, inclusive"
f"Can't set the perfume amount to {value}. Perfume amount must be an integer."
)
await self._diffuser.set_perfume_amount(int(value))

View File

@ -51,9 +51,4 @@ class DiffuserRoomSize(DiffuserEntity, SelectEntity):
async def async_select_option(self, option: str) -> None:
"""Change the diffuser room size."""
if option in self.options:
await self._diffuser.set_room_size_square_meter(int(option))
else:
raise ValueError(
f"Can't set the room size to {option}. Allowed room sizes are: {self.options}"
)
await self._diffuser.set_room_size_square_meter(int(option))