{"record":{"id":"2be9ad4124cf1ed0","repo":"home-assistant/core","slug":"authorization-required","errorCode":"AUTHORIZATION_REQUIRED","errorMessage":"You must disarm the system before you can set the requested arm state.","messagePattern":"You must disarm the system before you can set the requested arm state\\.","errorType":"exception","errorClass":"AlexaSecurityPanelAuthorizationRequired","httpStatus":null,"severity":"error","filePath":"homeassistant/components/alexa/handlers.py","lineNumber":1127,"sourceCode":"    config: AbstractConfig,\n    directive: AlexaDirective,\n    context: ha.Context,\n) -> AlexaResponse:\n    \"\"\"Process a Security Panel Arm request.\"\"\"\n    entity = directive.entity\n    service = None\n    arm_state = directive.payload[\"armState\"]\n    data: dict[str, Any] = {ATTR_ENTITY_ID: entity.entity_id}\n\n    # Per Alexa Documentation: users are not allowed to switch from armed_away\n    # directly to another armed state without first disarming the system.\n    # https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-securitypanelcontroller.html#arming\n    if (\n        entity.state == alarm_control_panel.AlarmControlPanelState.ARMED_AWAY\n        and arm_state != \"ARMED_AWAY\"\n    ):\n        msg = \"You must disarm the system before you can set the requested arm state.\"\n        raise AlexaSecurityPanelAuthorizationRequired(msg)\n\n    if arm_state == \"ARMED_AWAY\":\n        service = SERVICE_ALARM_ARM_AWAY\n    elif arm_state == \"ARMED_NIGHT\":\n        service = SERVICE_ALARM_ARM_NIGHT\n    elif arm_state == \"ARMED_STAY\":\n        service = SERVICE_ALARM_ARM_HOME\n    else:\n        raise AlexaInvalidDirectiveError(DIRECTIVE_NOT_SUPPORTED)\n\n    await hass.services.async_call(\n        entity.domain, service, data, blocking=False, context=context\n    )\n\n    # return 0 until alarm integration supports an exit delay\n    payload: dict[str, Any] = {\"exitDelayInSeconds\": 0}\n\n    response = directive.response(","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/alexa/handlers.py#L1109-L1145","documentation":"Alexa.SecurityPanelController.Arm enforces Amazon's rule that a panel armed_away cannot transition directly to another armed state. If the alarm_control_panel entity's state is ARMED_AWAY and the directive requests a different arm state, AlexaSecurityPanelAuthorizationRequired (AUTHORIZATION_REQUIRED) is raised before any service call.","triggerScenarios":"Saying 'arm stay' or 'arm night' while the panel is currently armed_away; scripted Alexa routines that arm to a different level without a prior disarm.","commonSituations":"House armed in away mode, then a voice assistant or geofence routine tries to switch to home/night arming; users unaware of the disarm-first requirement.","solutions":["Disarm first ('Alexa, disarm'), then issue the new arm command.","Update routines to chain disarm -> arm when changing arm levels.","Confirm nobody should be changing the arm state and treat the error as the expected safety behavior."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from homeassistant.components import alarm_control_panel as acp\n\nif (state.state == acp.AlarmControlPanelState.ARMED_AWAY\n        and requested_arm_state != 'ARMED_AWAY'):\n    await hass.services.async_call(\n        'alarm_control_panel', 'alarm_disarm', {'entity_id': eid, 'code': code},\n        blocking=True,\n    )","typeGuard":"def needs_disarm_first(current_state: str, requested: str) -> bool:\n    return current_state == 'armed_away' and requested != 'ARMED_AWAY'","tryCatchPattern":"try:\n    await process_directive(directive)\nexcept AlexaSecurityPanelAuthorizationRequired:\n    _LOGGER.info('Disarm required before switching from armed_away on %s', eid)","preventionTips":["Chain disarm then arm in routines that change arm levels.","Surface a 'disarm first' hint in UI flows when the panel is armed_away.","Treat AUTHORIZATION_REQUIRED from arm directives as expected behavior, not a bug."],"tags":["alexa","smart-home","alarm-control-panel","security","authorization"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}