diff --git a/homeassistant/components/siren/__init__.py b/homeassistant/components/siren/__init__.py index e5e03088a49..68770daf835 100644 --- a/homeassistant/components/siren/__init__.py +++ b/homeassistant/components/siren/__init__.py @@ -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) diff --git a/tests/components/siren/test_init.py b/tests/components/siren/test_init.py index e3b8bded6c8..6f90b8a9fcd 100644 --- a/tests/components/siren/test_init.py +++ b/tests/components/siren/test_init.py @@ -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):