{"record":{"id":"f5446c02a0f6a152","repo":"home-assistant/core","slug":"commands-not-found-cmds-not-found-r","errorCode":null,"errorMessage":"Commands not found: {cmds_not_found!r}","messagePattern":"Commands not found: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/broadlink/remote.py","lineNumber":480,"sourceCode":"            _LOGGER.error(\"Failed to call %s. %s\", service, err_msg)\n            raise ValueError(err_msg) from err\n\n        cmds_not_found = []\n        for command in commands:\n            try:\n                del codes[command]\n            except KeyError:\n                cmds_not_found.append(command)\n\n        if cmds_not_found:\n            if len(cmds_not_found) == 1:\n                err_msg = f\"Command not found: {cmds_not_found[0]!r}\"\n            else:\n                err_msg = f\"Commands not found: {cmds_not_found!r}\"\n\n            if len(cmds_not_found) == len(commands):\n                _LOGGER.error(\"Failed to call %s. %s\", service, err_msg)\n                raise ValueError(err_msg)\n\n            _LOGGER.error(\"Error during %s. %s\", service, err_msg)\n\n        # Clean up\n        if not codes:\n            del self._codes[subdevice]\n            if self._flags.pop(subdevice, None) is not None:\n                self._flag_storage.async_delay_save(self._get_flags, FLAG_SAVE_DELAY)\n\n        self._code_storage.async_delay_save(self._get_codes, CODE_SAVE_DELAY)\n","sourceCodeStart":462,"sourceCodeEnd":491,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/broadlink/remote.py#L462-L491","documentation":"Variant of the delete-command failure listing multiple missing commands (cmds_not_found has more than one entry). As with the single-command case, the ValueError is raised only when every requested command is missing; a partial miss is logged as 'Error during %s' and the delete continues for the commands that were found.","triggerScenarios":"Calling remote.delete_command with a list where none of the command names exist under the given subdevice; bulk-deleting commands from a script written against an older stored-codes layout.","commonSituations":"Re-running a bulk cleanup script after it already ran successfully; commands learned with different casing or naming (e.g. 'Power' vs 'power'); subdevice switched so the whole command set lives under another key.","solutions":["Fetch stored codes and diff the requested list against actual command names before calling delete","Normalize command names (case, separators) between learning and deletion scripts","If all commands are already gone, remove the delete step entirely","For mixed lists, split into found/not-found and only delete the found subset to avoid the all-missing raise"],"exampleFix":"# before\nawait remote_svc.async_call('remote', 'delete_command', {\n    'entity_id': 'remote.broadlink', 'device': 'tv',\n    'command': ['power', 'vol_up', 'hdmi1'],  # none exist\n})\n\n# after\nstored = await remote_svc.async_call('remote', 'get_stored_codes',\n    {'entity_id': 'remote.broadlink'}, blocking=True, return_response=True)\nknown = set(stored['remote.broadlink'].get('tv', {}))\nto_delete = [c for c in ['power', 'vol_up', 'hdmi1'] if c in known]\nif to_delete:\n    await remote_svc.async_call('remote', 'delete_command', {\n        'entity_id': 'remote.broadlink', 'device': 'tv', 'command': to_delete,\n    })","handlingStrategy":"validation","validationCode":"stored = await hass.services.async_call(\n    'remote', 'get_stored_codes',\n    {'entity_id': 'remote.broadlink'}, blocking=True, return_response=True,\n)\nknown = set(stored['remote.broadlink'].get(subdevice, {}))\nto_delete = [c for c in requested_commands if c in known]\n# only delete the intersection; skip when empty","typeGuard":null,"tryCatchPattern":"try:\n    await remote.async_delete_command(device=subdevice, command=command_list)\nexcept ValueError as err:\n    if 'Commands not found' in str(err):\n        # entire batch already absent; safe to ignore for idempotent cleanup\n        pass\n    else:\n        raise","preventionTips":["Diff bulk delete lists against stored codes before calling the service","Normalize naming conventions between learning sessions and cleanup scripts","Treat bulk delete scripts as one-shot: guard re-runs with an existence check"],"tags":["broadlink","remote","delete-command","bulk-operations","home-assistant"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}