From d2f8529519a740a44c8324e996a4ab74737a4002 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 17 May 2026 20:05:56 +0000 Subject: [PATCH 1/2] Fix Verisure alarm crash when cloud rejects arm/disarm command --- homeassistant/components/verisure/alarm_control_panel.py | 6 ++++++ homeassistant/components/verisure/strings.json | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index cb61e67e5d124f..30baa4995d9558 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -9,6 +9,7 @@ CodeFormat, ) from homeassistant.core import HomeAssistant, callback +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -63,6 +64,11 @@ async def _async_set_arm_state( self.coordinator.verisure.request, command_data ) LOGGER.debug("Verisure set arm state %s", state) + if arm_state is None or "data" not in arm_state: + raise HomeAssistantError( + translation_domain=DOMAIN, + translation_key="arm_state_failed", + ) result = None attempts = 0 while result is None: diff --git a/homeassistant/components/verisure/strings.json b/homeassistant/components/verisure/strings.json index 364f2690e78738..286e4cbb5822ef 100644 --- a/homeassistant/components/verisure/strings.json +++ b/homeassistant/components/verisure/strings.json @@ -51,6 +51,11 @@ } } }, + "exceptions": { + "arm_state_failed": { + "message": "Failed to change alarm state. Check your code and try again." + } + }, "options": { "step": { "init": { From f422852f5d23d1f3c3baa974955e2b92260ac716 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 17 May 2026 20:12:27 +0000 Subject: [PATCH 2/2] Address review: guard poll response, restore state on failure, mention rate limiting --- homeassistant/components/verisure/alarm_control_panel.py | 3 +++ homeassistant/components/verisure/strings.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index 30baa4995d9558..82e955f0c3a59e 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -65,6 +65,7 @@ async def _async_set_arm_state( ) LOGGER.debug("Verisure set arm state %s", state) if arm_state is None or "data" not in arm_state: + await self.coordinator.async_refresh() raise HomeAssistantError( translation_domain=DOMAIN, translation_key="arm_state_failed", @@ -83,6 +84,8 @@ async def _async_set_arm_state( list(arm_state["data"].values())[0], state ), ) + if transaction is None: + continue result = ( transaction.get("data", {}) .get("installation", {}) diff --git a/homeassistant/components/verisure/strings.json b/homeassistant/components/verisure/strings.json index 286e4cbb5822ef..797a455d69f629 100644 --- a/homeassistant/components/verisure/strings.json +++ b/homeassistant/components/verisure/strings.json @@ -53,7 +53,7 @@ }, "exceptions": { "arm_state_failed": { - "message": "Failed to change alarm state. Check your code and try again." + "message": "Failed to change alarm state. Verify your code is correct and that your account is not temporarily locked." } }, "options": {