Fix Blebox light scenes (#75106)
* Bug fix for light platform, when async_turn_on recieves multiple keys. * Changes according to @MartinHjelmare suggestion. * Moved effect set call in BleBoxLightEntity.async_turn_on method. * Added tests for effect in light platform. Added ValueError raise if effect not in effect list. * Removed duplicated line from test as @MartinHjelmare suggested.
This commit is contained in:
parent
c9df5888c2
commit
169264db66
2 changed files with 56 additions and 5 deletions
|
@ -159,15 +159,20 @@ class BleBoxLightEntity(BleBoxEntity, LightEntity):
|
|||
else:
|
||||
value = feature.apply_brightness(value, brightness)
|
||||
|
||||
try:
|
||||
await self._feature.async_on(value)
|
||||
except ValueError as exc:
|
||||
raise ValueError(
|
||||
f"Turning on '{self.name}' failed: Bad value {value}"
|
||||
) from exc
|
||||
|
||||
if effect is not None:
|
||||
effect_value = self.effect_list.index(effect)
|
||||
await self._feature.async_api_command("effect", effect_value)
|
||||
else:
|
||||
try:
|
||||
await self._feature.async_on(value)
|
||||
effect_value = self.effect_list.index(effect)
|
||||
await self._feature.async_api_command("effect", effect_value)
|
||||
except ValueError as exc:
|
||||
raise ValueError(
|
||||
f"Turning on '{self.name}' failed: Bad value {value}"
|
||||
f"Turning on with effect '{self.name}' failed: {effect} not in effect list."
|
||||
) from exc
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue