Remove deprecated supported features warning in Remote (#132643)

pull/132665/head
epenet 2024-12-09 08:32:30 +01:00 committed by GitHub
parent e0bb044782
commit f7ce112653
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 36 deletions

View File

@ -170,19 +170,6 @@ class RemoteEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_)
"""Flag supported features."""
return self._attr_supported_features
@property
def supported_features_compat(self) -> RemoteEntityFeature:
"""Return the supported features as RemoteEntityFeature.
Remove this compatibility shim in 2025.1 or later.
"""
features = self.supported_features
if type(features) is int: # noqa: E721
new_features = RemoteEntityFeature(features)
self._report_deprecated_supported_features_values(new_features)
return new_features
return features
@cached_property
def current_activity(self) -> str | None:
"""Active activity."""
@ -197,7 +184,7 @@ class RemoteEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_)
@property
def state_attributes(self) -> dict[str, Any] | None:
"""Return optional state attributes."""
if RemoteEntityFeature.ACTIVITY not in self.supported_features_compat:
if RemoteEntityFeature.ACTIVITY not in self.supported_features:
return None
return {

View File

@ -1,7 +1,5 @@
"""The tests for the Remote component, adapted from Light Test."""
import pytest
from homeassistant.components import remote
from homeassistant.components.remote import (
ATTR_ALTERNATIVE,
@ -142,23 +140,3 @@ async def test_delete_command(hass: HomeAssistant) -> None:
assert call.domain == remote.DOMAIN
assert call.service == SERVICE_DELETE_COMMAND
assert call.data[ATTR_ENTITY_ID] == ENTITY_ID
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
"""Test deprecated supported features ints."""
class MockRemote(remote.RemoteEntity):
@property
def supported_features(self) -> int:
"""Return supported features."""
return 1
entity = MockRemote()
assert entity.supported_features_compat is remote.RemoteEntityFeature(1)
assert "MockRemote" in caplog.text
assert "is using deprecated supported features values" in caplog.text
assert "Instead it should use" in caplog.text
assert "RemoteEntityFeature.LEARN_COMMAND" in caplog.text
caplog.clear()
assert entity.supported_features_compat is remote.RemoteEntityFeature(1)
assert "is using deprecated supported features values" not in caplog.text