Additional fixes for siren platform (#52971)

This commit is contained in:
Raman Gupta 2021-07-13 13:56:41 -04:00 committed by GitHub
parent 777fec62a5
commit 026ca4e4e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -63,11 +63,10 @@ def process_turn_on_params(
if not supported_features & SUPPORT_TONES:
params.pop(ATTR_TONE, None)
elif ATTR_TONE in params and (
not siren.available_tones
or (tone := params[ATTR_TONE]) not in siren.available_tones
elif (tone := params.get(ATTR_TONE)) is not None and (
not siren.available_tones or tone not in siren.available_tones
):
raise ValueError(f"Tone {tone} is not a valid tone for this device")
raise ValueError(f"Invalid tone received for entity {siren.entity_id}: {tone}")
if not supported_features & SUPPORT_DURATION:
params.pop(ATTR_DURATION, None)

View File

@ -9,10 +9,9 @@ class MockSirenEntity(SirenEntity):
_attr_is_on = True
@property
def supported_features(self) -> int:
"""Return the list of supported features."""
return 0
def __init__(self, supported_features: int = 0) -> None:
"""Initialize mock siren entity."""
self._attr_supported_features = supported_features
async def test_sync_turn_on(hass):