{"record":{"id":"469107a0ea916fd3","repo":"home-assistant/core","slug":"command-not-found-exiting-sequence","errorCode":null,"errorMessage":"Command not found. Exiting sequence","messagePattern":"Command not found\\. Exiting sequence","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/apple_tv/remote.py","lineNumber":93,"sourceCode":"        num_repeats = kwargs[ATTR_NUM_REPEATS]\n        delay = kwargs.get(ATTR_DELAY_SECS, DEFAULT_DELAY_SECS)\n        hold_secs = kwargs.get(ATTR_HOLD_SECS, DEFAULT_HOLD_SECS)\n\n        if not self.atv:\n            _LOGGER.error(\"Unable to send commands, not connected to %s\", self.name)\n            return\n\n        for _ in range(num_repeats):\n            for single_command in command:\n                attr_value: Any = None\n                if attributes := COMMAND_TO_ATTRIBUTE.get(single_command):\n                    attr_value = self.atv\n                    for attr_name in attributes:\n                        attr_value = getattr(attr_value, attr_name, None)\n                if not attr_value:\n                    attr_value = getattr(self.atv.remote_control, single_command, None)\n                if not attr_value:\n                    raise ValueError(\"Command not found. Exiting sequence\")\n\n                _LOGGER.debug(\"Sending command %s\", single_command)\n\n                if hold_secs >= 1:\n                    await attr_value(action=InputAction.Hold)\n                else:\n                    await attr_value()\n\n                await asyncio.sleep(delay)\n","sourceCodeStart":75,"sourceCodeEnd":103,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/apple_tv/remote.py#L75-L103","documentation":"ValueError('Command not found. Exiting sequence') raised by the apple_tv remote send_command handling when a command name in the sequence resolves to no callable. It first tries COMMAND_TO_ATTRIBUTE chained attribute lookup on the pyatv interface, then falls back to getattr(self.atv.remote_control, name); if both yield nothing, the sequence aborts immediately at that command.","triggerScenarios":"Sending 'send_command' with a key name that is neither a mapped multi-attribute path nor an attribute of pyatv's remote_control: typos like 'updown', renamed keys across pyatv versions, or device-specific keys the interface does not expose.","commonSituations":"Remote card sequences or scripts with mistyped key names; pyatv upgrade renaming/removing a RemoteKey; custom key names for newer Siri Remote buttons not present in the installed pyatv version.","solutions":["Use a valid pyatv remote control key name (e.g. 'menu', 'home', 'up', 'select', 'play_pause'); list them via 'atvremote ... command' or the pyatv docs","Fix the typo in the YAML sequence/dashboard button","If the key should exist, upgrade pyatv/apple_tv integration to a version that supports it"],"exampleFix":"# before\ndata: {command: [\"hom\", \"select\"]}\n# after\ndata: {command: [\"home\", \"select\"]}","handlingStrategy":"validation","validationCode":"KNOWN = {\"menu\", \"home\", \"up\", \"down\", \"left\", \"right\", \"select\", \"play_pause\"}\nseq = [c for c in command if c in KNOWN]\nif len(seq) != len(command):\n    raise ValueError(f\"unknown keys: {set(command) - KNOWN}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a project-level list of supported remote keys and lint sequences against it","Test sequences in Developer Tools before embedding in automations","After pyatv upgrades, re-verify key names"],"tags":["home-assistant","apple-tv","remote","pyatv","validation"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}