{"record":{"id":"f5a1e9a65db630c5","repo":"home-assistant/core","slug":"incorrect-door-state","errorCode":"incorrect_door_state","errorMessage":"incorrect_door_state","messagePattern":"incorrect_door_state","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"warning","filePath":"homeassistant/components/bosch_alarm/switch.py","lineNumber":118,"sourceCode":"    ) -> None:\n        \"\"\"Set up a switch entity for a door on a bosch alarm panel.\"\"\"\n        super().__init__(hass, panel, door_id, unique_id, config_entry_id)\n        self.entity_description = entity_description\n        self._attr_unique_id = f\"{self._door_unique_id}_{entity_description.key}\"\n\n    @property\n    @override\n    def is_on(self) -> bool:\n        \"\"\"Return the value function.\"\"\"\n        return self.entity_description.value_fn(self._door)\n\n    @override\n    async def async_turn_on(self, **kwargs: Any) -> None:\n        \"\"\"Run the on function.\"\"\"\n        # If the door is currently cycling, we can't send it\n        # any other commands until it is done\n        if self._door.is_cycling():\n            raise HomeAssistantError(\n                translation_domain=DOMAIN, translation_key=\"incorrect_door_state\"\n            )\n        await self.entity_description.on_fn(self.panel, self._door_id)\n\n    @override\n    async def async_turn_off(self, **kwargs: Any) -> None:\n        \"\"\"Run the off function.\"\"\"\n        # If the door is currently cycling, we can't send it\n        # any other commands until it is done\n        if self._door.is_cycling():\n            raise HomeAssistantError(\n                translation_domain=DOMAIN, translation_key=\"incorrect_door_state\"\n            )\n        await self.entity_description.off_fn(self.panel, self._door_id)\n\n\nclass PanelOutputEntity(BoschAlarmOutputEntity, SwitchEntity):\n    \"\"\"An output entity for a bosch alarm panel.\"\"\"","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/bosch_alarm/switch.py#L100-L136","documentation":"Raised by the bosch_alarm door switch entity's async_turn_on: before sending the open command it checks self._door.is_cycling(), and while the door is mid open/close cycle the panel cannot accept new commands, so it raises HomeAssistantError with translation_key 'incorrect_door_state'. This is a local state guard, not an API failure.","triggerScenarios":"Calling switch.turn_on (e.g. door open action) on a Bosch door while it is still travelling from a previous open/close command; rapid double commands in automations; door state not yet reported as settled by the panel.","commonSituations":"Automation firing twice on one event, garage-door style timing where users press again before travel completes, race between command and panel status update.","solutions":["Wait for the door cycle to finish (poll is_cycling / door state) before issuing the next command.","Debounce the automation — guard with a condition on the switch/door state.","If the door physically stopped but state says cycling, reload the integration to resync door state from the panel."],"exampleFix":"# before\nawait hass.services.async_call(\"switch\", \"turn_on\", {\"entity_id\": \"switch.door\"})\n# after\nif not switch._door.is_cycling():\n    await hass.services.async_call(\"switch\", \"turn_on\", {\"entity_id\": \"switch.door\"})","handlingStrategy":"validation","validationCode":"if switch._door.is_cycling():\n    raise ServiceValidationError(\"door_is_moving\")  # wait instead of commanding","typeGuard":"def door_ready_for_command(switch_entity) -> bool:\n    \"\"\"True when the door is not mid open/close cycle.\"\"\"\n    door = getattr(switch_entity, \"_door\", None)\n    return bool(door) and not door.is_cycling()","tryCatchPattern":"try:\n    await switch.async_turn_on()\nexcept HomeAssistantError as err:\n    if err.translation_key == \"incorrect_door_state\":\n        await asyncio.sleep(DOOR_TRAVEL_SECONDS)  # then retry once","preventionTips":["Debounce door automations to one command per cycle.","Condition door actions on the door/binary_sensor state, not just the switch."],"tags":["bosch-alarm","door","state-guard","home-assistant"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}