Rename Android TV to Android Debug Bridge (#90657)

* Rename Android TV to Android debug bridge

* More renaming
This commit is contained in:
tronikos 2023-04-02 11:22:16 -07:00 committed by GitHub
parent 17270979e6
commit b52fab0f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 80 additions and 79 deletions

View File

@ -1,4 +1,4 @@
"""Support for functionality to interact with Android TV/Fire TV devices.""" """Support for functionality to interact with Android/Fire TV devices."""
from __future__ import annotations from __future__ import annotations
from collections.abc import Mapping from collections.abc import Mapping
@ -135,11 +135,11 @@ async def async_connect_androidtv(
if not aftv.available: if not aftv.available:
# Determine the name that will be used for the device in the log # Determine the name that will be used for the device in the log
if config[CONF_DEVICE_CLASS] == DEVICE_ANDROIDTV: if config[CONF_DEVICE_CLASS] == DEVICE_ANDROIDTV:
device_name = "Android TV device" device_name = "Android device"
elif config[CONF_DEVICE_CLASS] == DEVICE_FIRETV: elif config[CONF_DEVICE_CLASS] == DEVICE_FIRETV:
device_name = "Fire TV device" device_name = "Fire TV device"
else: else:
device_name = "Android TV / Fire TV device" device_name = "Android / Fire TV device"
error_message = f"Could not connect to {device_name} at {address} {adb_log}" error_message = f"Could not connect to {device_name} at {address} {adb_log}"
return None, error_message return None, error_message
@ -148,7 +148,7 @@ async def async_connect_androidtv(
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Android TV platform.""" """Set up Android Debug Bridge platform."""
state_det_rules = entry.options.get(CONF_STATE_DETECTION_RULES) state_det_rules = entry.options.get(CONF_STATE_DETECTION_RULES)
if CONF_ADB_SERVER_IP not in entry.data: if CONF_ADB_SERVER_IP not in entry.data:
@ -167,7 +167,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
raise ConfigEntryNotReady(error_message) raise ConfigEntryNotReady(error_message)
async def async_close_connection(event): async def async_close_connection(event):
"""Close Android TV connection on HA Stop.""" """Close Android Debug Bridge connection on HA Stop."""
await aftv.adb_close() await aftv.adb_close()
entry.async_on_unload( entry.async_on_unload(

View File

@ -1,4 +1,4 @@
"""Config flow to configure the Android TV integration.""" """Config flow to configure the Android Debug Bridge integration."""
from __future__ import annotations from __future__ import annotations
import logging import logging
@ -114,13 +114,14 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN):
async def _async_check_connection( async def _async_check_connection(
self, user_input: dict[str, Any] self, user_input: dict[str, Any]
) -> tuple[str | None, str | None]: ) -> tuple[str | None, str | None]:
"""Attempt to connect the Android TV.""" """Attempt to connect the Android device."""
try: try:
aftv, error_message = await async_connect_androidtv(self.hass, user_input) aftv, error_message = await async_connect_androidtv(self.hass, user_input)
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
_LOGGER.exception( _LOGGER.exception(
"Unknown error connecting with Android TV at %s", user_input[CONF_HOST] "Unknown error connecting with Android device at %s",
user_input[CONF_HOST],
) )
return RESULT_UNKNOWN, None return RESULT_UNKNOWN, None
@ -130,7 +131,7 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN):
dev_prop = aftv.device_properties dev_prop = aftv.device_properties
_LOGGER.info( _LOGGER.info(
"Android TV at %s: %s = %r, %s = %r", "Android device at %s: %s = %r, %s = %r",
user_input[CONF_HOST], user_input[CONF_HOST],
PROP_ETHMAC, PROP_ETHMAC,
dev_prop.get(PROP_ETHMAC), dev_prop.get(PROP_ETHMAC),
@ -184,7 +185,7 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN):
class OptionsFlowHandler(OptionsFlowWithConfigEntry): class OptionsFlowHandler(OptionsFlowWithConfigEntry):
"""Handle an option flow for Android TV.""" """Handle an option flow for Android Debug Bridge."""
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow.""" """Initialize options flow."""

View File

@ -1,4 +1,4 @@
"""Android TV component constants.""" """Android Debug Bridge component constants."""
DOMAIN = "androidtv" DOMAIN = "androidtv"
ANDROID_DEV = DOMAIN ANDROID_DEV = DOMAIN

View File

@ -1,6 +1,6 @@
{ {
"domain": "androidtv", "domain": "androidtv",
"name": "Android TV", "name": "Android Debug Bridge",
"codeowners": ["@JeffLIrion", "@ollo69"], "codeowners": ["@JeffLIrion", "@ollo69"],
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/androidtv", "documentation": "https://www.home-assistant.io/integrations/androidtv",

View File

@ -1,4 +1,4 @@
"""Support for functionality to interact with Android TV / Fire TV devices.""" """Support for functionality to interact with Android / Fire TV devices."""
from __future__ import annotations from __future__ import annotations
from collections.abc import Awaitable, Callable, Coroutine from collections.abc import Awaitable, Callable, Coroutine
@ -87,7 +87,7 @@ async def async_setup_entry(
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: AddEntitiesCallback, async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up the Android TV entity.""" """Set up the Android Debug Bridge entity."""
aftv = hass.data[DOMAIN][entry.entry_id][ANDROID_DEV] aftv = hass.data[DOMAIN][entry.entry_id][ANDROID_DEV]
device_class = aftv.DEVICE_CLASS device_class = aftv.DEVICE_CLASS
device_type = ( device_type = (
@ -201,7 +201,7 @@ def adb_decorator(
class ADBDevice(MediaPlayerEntity): class ADBDevice(MediaPlayerEntity):
"""Representation of an Android TV or Fire TV device.""" """Representation of an Android or Fire TV device."""
_attr_device_class = MediaPlayerDeviceClass.TV _attr_device_class = MediaPlayerDeviceClass.TV
@ -214,7 +214,7 @@ class ADBDevice(MediaPlayerEntity):
entry_id, entry_id,
entry_data, entry_data,
): ):
"""Initialize the Android TV / Fire TV device.""" """Initialize the Android / Fire TV device."""
self.aftv = aftv self.aftv = aftv
self._attr_name = name self._attr_name = name
self._attr_unique_id = unique_id self._attr_unique_id = unique_id
@ -384,7 +384,7 @@ class ADBDevice(MediaPlayerEntity):
@adb_decorator() @adb_decorator()
async def adb_command(self, command): async def adb_command(self, command):
"""Send an ADB command to an Android TV / Fire TV device.""" """Send an ADB command to an Android / Fire TV device."""
if key := KEYS.get(command): if key := KEYS.get(command):
await self.aftv.adb_shell(f"input keyevent {key}") await self.aftv.adb_shell(f"input keyevent {key}")
return return
@ -422,13 +422,13 @@ class ADBDevice(MediaPlayerEntity):
persistent_notification.async_create( persistent_notification.async_create(
self.hass, self.hass,
msg, msg,
title="Android TV", title="Android Debug Bridge",
) )
_LOGGER.info("%s", msg) _LOGGER.info("%s", msg)
@adb_decorator() @adb_decorator()
async def service_download(self, device_path, local_path): async def service_download(self, device_path, local_path):
"""Download a file from your Android TV / Fire TV device to your Home Assistant instance.""" """Download a file from your Android / Fire TV device to your Home Assistant instance."""
if not self.hass.config.is_allowed_path(local_path): if not self.hass.config.is_allowed_path(local_path):
_LOGGER.warning("'%s' is not secure to load data from!", local_path) _LOGGER.warning("'%s' is not secure to load data from!", local_path)
return return
@ -437,7 +437,7 @@ class ADBDevice(MediaPlayerEntity):
@adb_decorator() @adb_decorator()
async def service_upload(self, device_path, local_path): async def service_upload(self, device_path, local_path):
"""Upload a file from your Home Assistant instance to an Android TV / Fire TV device.""" """Upload a file from your Home Assistant instance to an Android / Fire TV device."""
if not self.hass.config.is_allowed_path(local_path): if not self.hass.config.is_allowed_path(local_path):
_LOGGER.warning("'%s' is not secure to load data from!", local_path) _LOGGER.warning("'%s' is not secure to load data from!", local_path)
return return
@ -446,7 +446,7 @@ class ADBDevice(MediaPlayerEntity):
class AndroidTVDevice(ADBDevice): class AndroidTVDevice(ADBDevice):
"""Representation of an Android TV device.""" """Representation of an Android device."""
_attr_supported_features = ( _attr_supported_features = (
MediaPlayerEntityFeature.PAUSE MediaPlayerEntityFeature.PAUSE

View File

@ -1,8 +1,8 @@
# Describes the format for available Android TV and Fire TV services # Describes the format for available Android and Fire TV services
adb_command: adb_command:
name: ADB command name: ADB command
description: Send an ADB command to an Android TV / Fire TV device. description: Send an ADB command to an Android / Fire TV device.
target: target:
entity: entity:
integration: androidtv integration: androidtv
@ -17,7 +17,7 @@ adb_command:
text: text:
download: download:
name: Download name: Download
description: Download a file from your Android TV / Fire TV device to your Home Assistant instance. description: Download a file from your Android / Fire TV device to your Home Assistant instance.
target: target:
entity: entity:
integration: androidtv integration: androidtv
@ -25,7 +25,7 @@ download:
fields: fields:
device_path: device_path:
name: Device path name: Device path
description: The filepath on the Android TV / Fire TV device. description: The filepath on the Android / Fire TV device.
required: true required: true
example: "/storage/emulated/0/Download/example.txt" example: "/storage/emulated/0/Download/example.txt"
selector: selector:
@ -39,7 +39,7 @@ download:
text: text:
upload: upload:
name: Upload name: Upload
description: Upload a file from your Home Assistant instance to an Android TV / Fire TV device. description: Upload a file from your Home Assistant instance to an Android / Fire TV device.
target: target:
entity: entity:
integration: androidtv integration: androidtv
@ -47,7 +47,7 @@ upload:
fields: fields:
device_path: device_path:
name: Device path name: Device path
description: The filepath on the Android TV / Fire TV device. description: The filepath on the Android / Fire TV device.
required: true required: true
example: "/storage/emulated/0/Download/example.txt" example: "/storage/emulated/0/Download/example.txt"
selector: selector:

View File

@ -38,7 +38,7 @@
} }
}, },
"apps": { "apps": {
"title": "Configure Android TV Apps", "title": "Configure Android Apps",
"description": "Configure application id {app_id}", "description": "Configure application id {app_id}",
"data": { "data": {
"app_name": "Application Name", "app_name": "Application Name",
@ -47,7 +47,7 @@
} }
}, },
"rules": { "rules": {
"title": "Configure Android TV state detection rules", "title": "Configure Android state detection rules",
"description": "Configure detection rule for application id {rule_id}", "description": "Configure detection rule for application id {rule_id}",
"data": { "data": {
"rule_id": "Application ID", "rule_id": "Application ID",

View File

@ -241,7 +241,7 @@
"iot_class": "local_polling" "iot_class": "local_polling"
}, },
"androidtv": { "androidtv": {
"name": "Android TV", "name": "Android Debug Bridge",
"integration_type": "device", "integration_type": "device",
"config_flow": true, "config_flow": true,
"iot_class": "local_polling" "iot_class": "local_polling"

View File

@ -48,14 +48,14 @@ INVALID_MAC = "ff:ff:ff:ff:ff:ff"
HOST = "127.0.0.1" HOST = "127.0.0.1"
VALID_DETECT_RULE = [{"paused": {"media_session_state": 3}}] VALID_DETECT_RULE = [{"paused": {"media_session_state": 3}}]
# Android TV device with Python ADB implementation # Android device with Python ADB implementation
CONFIG_PYTHON_ADB = { CONFIG_PYTHON_ADB = {
CONF_HOST: HOST, CONF_HOST: HOST,
CONF_PORT: DEFAULT_PORT, CONF_PORT: DEFAULT_PORT,
CONF_DEVICE_CLASS: DEVICE_ANDROIDTV, CONF_DEVICE_CLASS: DEVICE_ANDROIDTV,
} }
# Android TV device with ADB server # Android device with ADB server
CONFIG_ADB_SERVER = { CONFIG_ADB_SERVER = {
CONF_HOST: HOST, CONF_HOST: HOST,
CONF_PORT: DEFAULT_PORT, CONF_PORT: DEFAULT_PORT,
@ -70,7 +70,7 @@ CONNECT_METHOD = (
class MockConfigDevice: class MockConfigDevice:
"""Mock class to emulate Android TV device.""" """Mock class to emulate Android device."""
def __init__(self, eth_mac=ETH_MAC, wifi_mac=None): def __init__(self, eth_mac=ETH_MAC, wifi_mac=None):
"""Initialize a fake device to test config flow.""" """Initialize a fake device to test config flow."""

View File

@ -95,8 +95,8 @@ MSG_RECONNECT = {
SHELL_RESPONSE_OFF = "" SHELL_RESPONSE_OFF = ""
SHELL_RESPONSE_STANDBY = "1" SHELL_RESPONSE_STANDBY = "1"
# Android TV device with Python ADB implementation # Android device with Python ADB implementation
CONFIG_ANDROIDTV_PYTHON_ADB = { CONFIG_ANDROID_PYTHON_ADB = {
ADB_PATCH_KEY: patchers.KEY_PYTHON, ADB_PATCH_KEY: patchers.KEY_PYTHON,
TEST_ENTITY_NAME: f"{PREFIX_ANDROIDTV} {HOST}", TEST_ENTITY_NAME: f"{PREFIX_ANDROIDTV} {HOST}",
DOMAIN: { DOMAIN: {
@ -106,28 +106,28 @@ CONFIG_ANDROIDTV_PYTHON_ADB = {
}, },
} }
# Android TV device with Python ADB implementation imported from YAML # Android device with Python ADB implementation imported from YAML
CONFIG_ANDROIDTV_PYTHON_ADB_YAML = { CONFIG_ANDROID_PYTHON_ADB_YAML = {
ADB_PATCH_KEY: patchers.KEY_PYTHON, ADB_PATCH_KEY: patchers.KEY_PYTHON,
TEST_ENTITY_NAME: "ADB yaml import", TEST_ENTITY_NAME: "ADB yaml import",
DOMAIN: { DOMAIN: {
CONF_NAME: "ADB yaml import", CONF_NAME: "ADB yaml import",
**CONFIG_ANDROIDTV_PYTHON_ADB[DOMAIN], **CONFIG_ANDROID_PYTHON_ADB[DOMAIN],
}, },
} }
# Android TV device with Python ADB implementation with custom adbkey # Android device with Python ADB implementation with custom adbkey
CONFIG_ANDROIDTV_PYTHON_ADB_KEY = { CONFIG_ANDROID_PYTHON_ADB_KEY = {
ADB_PATCH_KEY: patchers.KEY_PYTHON, ADB_PATCH_KEY: patchers.KEY_PYTHON,
TEST_ENTITY_NAME: CONFIG_ANDROIDTV_PYTHON_ADB[TEST_ENTITY_NAME], TEST_ENTITY_NAME: CONFIG_ANDROID_PYTHON_ADB[TEST_ENTITY_NAME],
DOMAIN: { DOMAIN: {
**CONFIG_ANDROIDTV_PYTHON_ADB[DOMAIN], **CONFIG_ANDROID_PYTHON_ADB[DOMAIN],
CONF_ADBKEY: "user_provided_adbkey", CONF_ADBKEY: "user_provided_adbkey",
}, },
} }
# Android TV device with ADB server # Android device with ADB server
CONFIG_ANDROIDTV_ADB_SERVER = { CONFIG_ANDROID_ADB_SERVER = {
ADB_PATCH_KEY: patchers.KEY_SERVER, ADB_PATCH_KEY: patchers.KEY_SERVER,
TEST_ENTITY_NAME: f"{PREFIX_ANDROIDTV} {HOST}", TEST_ENTITY_NAME: f"{PREFIX_ANDROIDTV} {HOST}",
DOMAIN: { DOMAIN: {
@ -163,7 +163,7 @@ CONFIG_FIRETV_ADB_SERVER = {
}, },
} }
CONFIG_ANDROIDTV_DEFAULT = CONFIG_ANDROIDTV_PYTHON_ADB CONFIG_ANDROID_DEFAULT = CONFIG_ANDROID_PYTHON_ADB
CONFIG_FIRETV_DEFAULT = CONFIG_FIRETV_PYTHON_ADB CONFIG_FIRETV_DEFAULT = CONFIG_FIRETV_PYTHON_ADB
@ -213,10 +213,10 @@ def _setup(config):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"config", "config",
[ [
CONFIG_ANDROIDTV_PYTHON_ADB, CONFIG_ANDROID_PYTHON_ADB,
CONFIG_ANDROIDTV_PYTHON_ADB_YAML, CONFIG_ANDROID_PYTHON_ADB_YAML,
CONFIG_FIRETV_PYTHON_ADB, CONFIG_FIRETV_PYTHON_ADB,
CONFIG_ANDROIDTV_ADB_SERVER, CONFIG_ANDROID_ADB_SERVER,
CONFIG_FIRETV_ADB_SERVER, CONFIG_FIRETV_ADB_SERVER,
], ],
) )
@ -275,9 +275,9 @@ async def test_reconnect(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"config", "config",
[ [
CONFIG_ANDROIDTV_PYTHON_ADB, CONFIG_ANDROID_PYTHON_ADB,
CONFIG_FIRETV_PYTHON_ADB, CONFIG_FIRETV_PYTHON_ADB,
CONFIG_ANDROIDTV_ADB_SERVER, CONFIG_ANDROID_ADB_SERVER,
CONFIG_FIRETV_ADB_SERVER, CONFIG_FIRETV_ADB_SERVER,
], ],
) )
@ -313,7 +313,7 @@ async def test_adb_shell_returns_none(
async def test_setup_with_adbkey(hass: HomeAssistant) -> None: async def test_setup_with_adbkey(hass: HomeAssistant) -> None:
"""Test that setup succeeds when using an ADB key.""" """Test that setup succeeds when using an ADB key."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_PYTHON_ADB_KEY) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_PYTHON_ADB_KEY)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(
@ -331,12 +331,12 @@ async def test_setup_with_adbkey(hass: HomeAssistant) -> None:
@pytest.mark.parametrize( @pytest.mark.parametrize(
"config", "config",
[ [
CONFIG_ANDROIDTV_DEFAULT, CONFIG_ANDROID_DEFAULT,
CONFIG_FIRETV_DEFAULT, CONFIG_FIRETV_DEFAULT,
], ],
) )
async def test_sources(hass: HomeAssistant, config: dict[str, Any]) -> None: async def test_sources(hass: HomeAssistant, config: dict[str, Any]) -> None:
"""Test that sources (i.e., apps) are handled correctly for Android TV and Fire TV devices.""" """Test that sources (i.e., apps) are handled correctly for Android and Fire TV devices."""
conf_apps = { conf_apps = {
"com.app.test1": "TEST 1", "com.app.test1": "TEST 1",
"com.app.test3": None, "com.app.test3": None,
@ -397,7 +397,7 @@ async def test_sources(hass: HomeAssistant, config: dict[str, Any]) -> None:
@pytest.mark.parametrize( @pytest.mark.parametrize(
("config", "expected_sources"), ("config", "expected_sources"),
[ [
(CONFIG_ANDROIDTV_DEFAULT, ["TEST 1"]), (CONFIG_ANDROID_DEFAULT, ["TEST 1"]),
(CONFIG_FIRETV_DEFAULT, ["TEST 1"]), (CONFIG_FIRETV_DEFAULT, ["TEST 1"]),
], ],
) )
@ -503,7 +503,7 @@ async def test_select_source_androidtv(
"com.app.test3": None, "com.app.test3": None,
} }
await _test_select_source( await _test_select_source(
hass, CONFIG_ANDROIDTV_DEFAULT, conf_apps, source, expected_arg, method_patch hass, CONFIG_ANDROID_DEFAULT, conf_apps, source, expected_arg, method_patch
) )
@ -517,7 +517,7 @@ async def test_androidtv_select_source_overridden_app_name(hass: HomeAssistant)
assert "com.youtube.test" not in ANDROIDTV_APPS assert "com.youtube.test" not in ANDROIDTV_APPS
await _test_select_source( await _test_select_source(
hass, hass,
CONFIG_ANDROIDTV_PYTHON_ADB, CONFIG_ANDROID_PYTHON_ADB,
conf_apps, conf_apps,
"YouTube", "YouTube",
"com.youtube.test", "com.youtube.test",
@ -554,9 +554,9 @@ async def test_select_source_firetv(
@pytest.mark.parametrize( @pytest.mark.parametrize(
("config", "connect"), ("config", "connect"),
[ [
(CONFIG_ANDROIDTV_DEFAULT, False), (CONFIG_ANDROID_DEFAULT, False),
(CONFIG_FIRETV_DEFAULT, False), (CONFIG_FIRETV_DEFAULT, False),
(CONFIG_ANDROIDTV_DEFAULT, True), (CONFIG_ANDROID_DEFAULT, True),
(CONFIG_FIRETV_DEFAULT, True), (CONFIG_FIRETV_DEFAULT, True),
], ],
) )
@ -581,7 +581,7 @@ async def test_setup_fail(
async def test_adb_command(hass: HomeAssistant) -> None: async def test_adb_command(hass: HomeAssistant) -> None:
"""Test sending a command via the `androidtv.adb_command` service.""" """Test sending a command via the `androidtv.adb_command` service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
command = "test command" command = "test command"
response = "test response" response = "test response"
@ -610,7 +610,7 @@ async def test_adb_command(hass: HomeAssistant) -> None:
async def test_adb_command_unicode_decode_error(hass: HomeAssistant) -> None: async def test_adb_command_unicode_decode_error(hass: HomeAssistant) -> None:
"""Test sending a command via the `androidtv.adb_command` service that raises a UnicodeDecodeError exception.""" """Test sending a command via the `androidtv.adb_command` service that raises a UnicodeDecodeError exception."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
command = "test command" command = "test command"
response = b"test response" response = b"test response"
@ -639,7 +639,7 @@ async def test_adb_command_unicode_decode_error(hass: HomeAssistant) -> None:
async def test_adb_command_key(hass: HomeAssistant) -> None: async def test_adb_command_key(hass: HomeAssistant) -> None:
"""Test sending a key command via the `androidtv.adb_command` service.""" """Test sending a key command via the `androidtv.adb_command` service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
command = "HOME" command = "HOME"
response = None response = None
@ -668,7 +668,7 @@ async def test_adb_command_key(hass: HomeAssistant) -> None:
async def test_adb_command_get_properties(hass: HomeAssistant) -> None: async def test_adb_command_get_properties(hass: HomeAssistant) -> None:
"""Test sending the "GET_PROPERTIES" command via the `androidtv.adb_command` service.""" """Test sending the "GET_PROPERTIES" command via the `androidtv.adb_command` service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
command = "GET_PROPERTIES" command = "GET_PROPERTIES"
response = {"test key": "test value"} response = {"test key": "test value"}
@ -698,7 +698,7 @@ async def test_adb_command_get_properties(hass: HomeAssistant) -> None:
async def test_learn_sendevent(hass: HomeAssistant) -> None: async def test_learn_sendevent(hass: HomeAssistant) -> None:
"""Test the `androidtv.learn_sendevent` service.""" """Test the `androidtv.learn_sendevent` service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
response = "sendevent 1 2 3 4" response = "sendevent 1 2 3 4"
@ -727,7 +727,7 @@ async def test_learn_sendevent(hass: HomeAssistant) -> None:
async def test_update_lock_not_acquired(hass: HomeAssistant) -> None: async def test_update_lock_not_acquired(hass: HomeAssistant) -> None:
"""Test that the state does not get updated when a `LockNotAcquiredException` is raised.""" """Test that the state does not get updated when a `LockNotAcquiredException` is raised."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(
@ -760,7 +760,7 @@ async def test_update_lock_not_acquired(hass: HomeAssistant) -> None:
async def test_download(hass: HomeAssistant) -> None: async def test_download(hass: HomeAssistant) -> None:
"""Test the `androidtv.download` service.""" """Test the `androidtv.download` service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
device_path = "device/path" device_path = "device/path"
local_path = "local/path" local_path = "local/path"
@ -806,7 +806,7 @@ async def test_download(hass: HomeAssistant) -> None:
async def test_upload(hass: HomeAssistant) -> None: async def test_upload(hass: HomeAssistant) -> None:
"""Test the `androidtv.upload` service.""" """Test the `androidtv.upload` service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
device_path = "device/path" device_path = "device/path"
local_path = "local/path" local_path = "local/path"
@ -851,8 +851,8 @@ async def test_upload(hass: HomeAssistant) -> None:
async def test_androidtv_volume_set(hass: HomeAssistant) -> None: async def test_androidtv_volume_set(hass: HomeAssistant) -> None:
"""Test setting the volume for an Android TV device.""" """Test setting the volume for an Android device."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(
@ -881,7 +881,7 @@ async def test_get_image_http(
This is based on `test_get_image_http` in tests/components/media_player/test_init.py. This is based on `test_get_image_http` in tests/components/media_player/test_init.py.
""" """
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(
@ -894,7 +894,7 @@ async def test_get_image_http(
await async_update_entity(hass, entity_id) await async_update_entity(hass, entity_id)
media_player_name = "media_player." + slugify( media_player_name = "media_player." + slugify(
CONFIG_ANDROIDTV_DEFAULT[TEST_ENTITY_NAME] CONFIG_ANDROID_DEFAULT[TEST_ENTITY_NAME]
) )
state = hass.states.get(media_player_name) state = hass.states.get(media_player_name)
assert "entity_picture_local" not in state.attributes assert "entity_picture_local" not in state.attributes
@ -923,7 +923,7 @@ async def test_get_image_http(
async def test_get_image_disabled(hass: HomeAssistant) -> None: async def test_get_image_disabled(hass: HomeAssistant) -> None:
"""Test that the screencap option can disable entity_picture.""" """Test that the screencap option can disable entity_picture."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
hass.config_entries.async_update_entry( hass.config_entries.async_update_entry(
config_entry, options={CONF_SCREENCAP: False} config_entry, options={CONF_SCREENCAP: False}
@ -939,7 +939,7 @@ async def test_get_image_disabled(hass: HomeAssistant) -> None:
await async_update_entity(hass, entity_id) await async_update_entity(hass, entity_id)
media_player_name = "media_player." + slugify( media_player_name = "media_player." + slugify(
CONFIG_ANDROIDTV_DEFAULT[TEST_ENTITY_NAME] CONFIG_ANDROID_DEFAULT[TEST_ENTITY_NAME]
) )
state = hass.states.get(media_player_name) state = hass.states.get(media_player_name)
assert "entity_picture_local" not in state.attributes assert "entity_picture_local" not in state.attributes
@ -954,7 +954,7 @@ async def _test_service(
additional_service_data=None, additional_service_data=None,
return_value=None, return_value=None,
): ):
"""Test generic Android TV media player entity service.""" """Test generic Android media player entity service."""
service_data = {ATTR_ENTITY_ID: entity_id} service_data = {ATTR_ENTITY_ID: entity_id}
if additional_service_data: if additional_service_data:
service_data.update(additional_service_data) service_data.update(additional_service_data)
@ -977,8 +977,8 @@ async def _test_service(
async def test_services_androidtv(hass: HomeAssistant) -> None: async def test_services_androidtv(hass: HomeAssistant) -> None:
"""Test media player services for an Android TV device.""" """Test media player services for an Android device."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key]: with patchers.patch_connect(True)[patch_key]:
@ -1042,7 +1042,7 @@ async def test_services_firetv(hass: HomeAssistant) -> None:
async def test_volume_mute(hass: HomeAssistant) -> None: async def test_volume_mute(hass: HomeAssistant) -> None:
"""Test the volume mute service.""" """Test the volume mute service."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key]: with patchers.patch_connect(True)[patch_key]:
@ -1085,7 +1085,7 @@ async def test_volume_mute(hass: HomeAssistant) -> None:
async def test_connection_closed_on_ha_stop(hass: HomeAssistant) -> None: async def test_connection_closed_on_ha_stop(hass: HomeAssistant) -> None:
"""Test that the ADB socket connection is closed when HA stops.""" """Test that the ADB socket connection is closed when HA stops."""
patch_key, _, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, _, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(
@ -1105,7 +1105,7 @@ async def test_exception(hass: HomeAssistant) -> None:
HA will attempt to reconnect on the next update. HA will attempt to reconnect on the next update.
""" """
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(
@ -1135,7 +1135,7 @@ async def test_exception(hass: HomeAssistant) -> None:
async def test_options_reload(hass: HomeAssistant) -> None: async def test_options_reload(hass: HomeAssistant) -> None:
"""Test changing an option that will cause integration reload.""" """Test changing an option that will cause integration reload."""
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT) patch_key, entity_id, config_entry = _setup(CONFIG_ANDROID_DEFAULT)
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patchers.patch_connect(True)[patch_key], patchers.patch_shell( with patchers.patch_connect(True)[patch_key], patchers.patch_shell(