Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/apple_tv/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([AppleTVRemote(atv, power, name)])


class AppleTVRemote(remote.RemoteDevice):
class AppleTVRemote(remote.RemoteEntity):
"""Device that sends commands to an Apple TV."""

def __init__(self, atv, power, name):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/broadlink/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
DOMAIN as COMPONENT,
PLATFORM_SCHEMA,
SUPPORT_LEARN_COMMAND,
RemoteDevice,
RemoteEntity,
)
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE
from homeassistant.core import callback
Expand Down Expand Up @@ -124,7 +124,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([remote], False)


class BroadlinkRemote(RemoteDevice):
class BroadlinkRemote(RemoteEntity):
"""Representation of a Broadlink remote."""

def __init__(self, name, unique_id, api, code_storage, flag_storage):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/demo/remote.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Demo platform that has two fake remotes."""
from homeassistant.components.remote import RemoteDevice
from homeassistant.components.remote import RemoteEntity
from homeassistant.const import DEVICE_DEFAULT_NAME


Expand All @@ -18,7 +18,7 @@ def setup_platform(hass, config, add_entities_callback, discovery_info=None):
)


class DemoRemote(RemoteDevice):
class DemoRemote(RemoteEntity):
"""Representation of a demo remote."""

def __init__(self, name, state, icon):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/directv/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from directv import DIRECTV, DIRECTVError

from homeassistant.components.remote import RemoteDevice
from homeassistant.components.remote import RemoteEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType

Expand Down Expand Up @@ -36,7 +36,7 @@ async def async_setup_entry(
async_add_entities(entities, True)


class DIRECTVRemote(DIRECTVEntity, RemoteDevice):
class DIRECTVRemote(DIRECTVEntity, RemoteEntity):
"""Device that sends commands to a DirecTV receiver."""

def __init__(self, *, dtv: DIRECTV, name: str, address: str = "0") -> None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/harmony/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def async_setup_entry(
)


class HarmonyRemote(remote.RemoteDevice):
class HarmonyRemote(remote.RemoteEntity):
"""Remote representation used to control a Harmony device."""

def __init__(self, name, unique_id, host, activity, out_path, delay_secs):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/itach/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return True


class ITachIP2IRRemote(remote.RemoteDevice):
class ITachIP2IRRemote(remote.RemoteEntity):
"""Device that sends commands to an ITachIP2IR device."""

def __init__(self, itachip2ir, name):
Expand Down
14 changes: 13 additions & 1 deletion homeassistant/components/remote/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> boo
return await cast(EntityComponent, hass.data[DOMAIN]).async_unload_entry(entry)


class RemoteDevice(ToggleEntity):
class RemoteEntity(ToggleEntity):
"""Representation of a remote."""

@property
Expand All @@ -149,3 +149,15 @@ async def async_learn_command(self, **kwargs: Any) -> None:
"""Learn a command from a device."""
assert self.hass is not None
await self.hass.async_add_executor_job(ft.partial(self.learn_command, **kwargs))


class RemoteDevice(RemoteEntity):
"""Representation of a remote (for backwards compatibility)."""

def __init_subclass__(cls, **kwargs):
"""Print deprecation warning."""
super().__init_subclass__(**kwargs)
_LOGGER.warning(
"RemoteDevice is deprecated, modify %s to extend RemoteEntity",
cls.__name__,
)
4 changes: 2 additions & 2 deletions homeassistant/components/roku/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)
from roku import RokuException

from homeassistant.components.remote import RemoteDevice
from homeassistant.components.remote import RemoteEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType

Expand All @@ -24,7 +24,7 @@ async def async_setup_entry(
async_add_entities([RokuRemote(roku)], True)


class RokuRemote(RemoteDevice):
class RokuRemote(RemoteEntity):
"""Device that sends commands to an Roku."""

def __init__(self, roku):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/xiaomi_miio/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ATTR_NUM_REPEATS,
DEFAULT_DELAY_SECS,
PLATFORM_SCHEMA,
RemoteDevice,
RemoteEntity,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
Expand Down Expand Up @@ -165,7 +165,7 @@ async def async_service_handler(service):
)


class XiaomiMiioRemote(RemoteDevice):
class XiaomiMiioRemote(RemoteEntity):
"""Representation of a Xiaomi Miio Remote device."""

def __init__(self, friendly_name, device, unique_id, slot, timeout, commands):
Expand Down
10 changes: 10 additions & 0 deletions tests/components/remote/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ def test_learn_command(self):
assert call.domain == remote.DOMAIN
assert call.service == SERVICE_LEARN_COMMAND
assert call.data[ATTR_ENTITY_ID] == "entity_id_val"


def test_deprecated_base_class(caplog):
"""Test deprecated base class."""

class CustomRemote(remote.RemoteDevice):
pass

CustomRemote()
assert "RemoteDevice is deprecated, modify CustomRemote" in caplog.text