Remove deprecated supported features warning in Remote (#132643)
parent
e0bb044782
commit
f7ce112653
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue