Remove deprecated supported features warning in Siren (#132666)

This commit is contained in:
epenet 2024-12-09 10:19:07 +01:00 committed by GitHub
parent 427db02029
commit 31150bf897
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 24 deletions

View File

@ -191,9 +191,4 @@ class SirenEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
@cached_property
def supported_features(self) -> SirenEntityFeature:
"""Return the list of supported features."""
features = self._attr_supported_features
if type(features) is int: # noqa: E721
new_features = SirenEntityFeature(features)
self._report_deprecated_supported_features_values(new_features)
return new_features
return features
return self._attr_supported_features

View File

@ -4,7 +4,6 @@ from unittest.mock import MagicMock
import pytest
from homeassistant.components import siren
from homeassistant.components.siren import (
SirenEntity,
SirenEntityDescription,
@ -106,20 +105,3 @@ async def test_missing_tones_dict(hass: HomeAssistant) -> None:
siren.hass = hass
with pytest.raises(ValueError):
process_turn_on_params(siren, {"tone": 3})
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
"""Test deprecated supported features ints."""
class MockSirenEntity(siren.SirenEntity):
_attr_supported_features = 1
entity = MockSirenEntity()
assert entity.supported_features is siren.SirenEntityFeature(1)
assert "MockSirenEntity" in caplog.text
assert "is using deprecated supported features values" in caplog.text
assert "Instead it should use" in caplog.text
assert "SirenEntityFeature.TURN_ON" in caplog.text
caplog.clear()
assert entity.supported_features is siren.SirenEntityFeature(1)
assert "is using deprecated supported features values" not in caplog.text