home-assistant/core · error · ServiceValidationError
failed_send
failed_send
Error message
Failed to send command {cmd} What it means
Raised as ServiceValidationError with translation key failed_send when aftv.adb_shell(cmd) throws UnicodeDecodeError while sending a remote command. The ADB shell response bytes could not be decoded, usually because the constructed command string was malformed or the device returned binary/garbage output. Being a ServiceValidationError it surfaces as a user-facing action error, not a crash or retry.
Source
Thrown at homeassistant/components/androidtv/remote.py:74
@adb_decorator()
@override
async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None:
"""Send a command to a device."""
num_repeats = kwargs[ATTR_NUM_REPEATS]
command_list = []
for cmd in command:
if key := KEYS.get(cmd):
command_list.append(f"input keyevent {key}")
else:
command_list.append(cmd)
for _ in range(num_repeats):
for cmd in command_list:
try:
await self.aftv.adb_shell(cmd)
except UnicodeDecodeError as ex:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="failed_send",
translation_placeholders={"cmd": cmd},
) from ex
View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Check the exact cmd in the error placeholder; replace it with a known key name from KEYS or a plain ASCII adb shell command.
- Test the same command via 'adb shell <cmd>' from a computer to confirm it is valid.
- Update the androidtv integration so new key mappings are available instead of raw strings.
- Avoid non-ASCII characters in commands; ADB shell transport is not Unicode-safe.
Example fix
// before (automation) action: androidtv.remote.send_command data: command: "VOLUME_Up " // after action: androidtv.remote.send_command data: command: "VOLUME_UP"
Defensive patterns
Strategy: validation
Validate before calling
from homeassistant.components.androidtv.remote import KEYS
command = 'VOLUME_UP'
assert command in KEYS or command.isascii(), f'unknown command {command}' Type guard
def is_sendable_command(cmd: str) -> bool:
return cmd in KEYS or (cmd.isascii() and '\n' not in cmd) Try / catch
ServiceValidationError surfaces as a UI error on the action call — validate inputs before invoking instead of catching.
Prevention
- Use canonical key names from the integration's KEYS mapping.
- Avoid non-ASCII/escaped strings in adb shell commands.
- Keep the integration updated so new key names are mapped.
When it happens
Trigger: Calling the androidtv remote send_command action where a command not in KEYS is passed through verbatim; if it contains characters that break ADB shell encoding, adb_shell raises UnicodeDecodeError and the action aborts with 'Failed to send command {cmd}'.
Common situations: Custom/raw shell commands in automations or YAML scripts with non-ASCII or escaping problems, device firmware returning unexpected bytes, or a stale key mapping name that falls through KEYS.
Related errors
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/b2ae82673cc5d657.
Report an issue: GitHub.