From e54540ea0645bf73ff136f91f137d6b772f035b1 Mon Sep 17 00:00:00 2001 From: Oluwatobi Mustapha Date: Mon, 24 Aug 2026 22:05:32 +0100 Subject: [PATCH] Abode: report change setting failures (#179756) --- homeassistant/components/abode/services.py | 10 ++++++--- homeassistant/components/abode/strings.json | 5 +++++ tests/components/abode/test_init.py | 24 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/abode/services.py b/homeassistant/components/abode/services.py index 7c1321a58c36..a650507959e3 100644 --- a/homeassistant/components/abode/services.py +++ b/homeassistant/components/abode/services.py @@ -7,10 +7,11 @@ import voluptuous as vol from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall, callback +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv, service from homeassistant.helpers.dispatcher import dispatcher_send -from .const import DOMAIN, LOGGER +from .const import DOMAIN if TYPE_CHECKING: from . import AbodeConfigEntry, AbodeSystem @@ -41,9 +42,12 @@ def _change_setting(call: ServiceCall) -> None: try: _get_abode_system(call.hass).abode.set_setting(setting, value) - # pylint: disable-next=home-assistant-action-swallowed-exception except AbodeException as ex: - LOGGER.warning(ex) + raise HomeAssistantError( + translation_domain=DOMAIN, + translation_key="change_setting_failed", + translation_placeholders={"error": str(ex)}, + ) from ex def _capture_image(call: ServiceCall) -> None: diff --git a/homeassistant/components/abode/strings.json b/homeassistant/components/abode/strings.json index 063bcafea8ad..c706a0b91aa6 100644 --- a/homeassistant/components/abode/strings.json +++ b/homeassistant/components/abode/strings.json @@ -31,6 +31,11 @@ } } }, + "exceptions": { + "change_setting_failed": { + "message": "Failed to change Abode setting: {error}" + } + }, "services": { "capture_image": { "description": "Requests a new image capture from a camera device.", diff --git a/tests/components/abode/test_init.py b/tests/components/abode/test_init.py index 0ef1f2c92fc9..51c1c40d8b37 100644 --- a/tests/components/abode/test_init.py +++ b/tests/components/abode/test_init.py @@ -7,12 +7,14 @@ from jaraco.abode.exceptions import ( AuthenticationException as AbodeAuthenticationException, Exception as AbodeException, ) +import pytest from homeassistant.components.abode.const import DOMAIN from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_USERNAME from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError from .common import setup_platform @@ -32,6 +34,28 @@ async def test_change_settings(hass: HomeAssistant) -> None: mock_set_setting.assert_called_once() +async def test_change_settings_error(hass: HomeAssistant) -> None: + """Test change_setting service reports errors.""" + await setup_platform(hass, ALARM_DOMAIN) + + with ( + patch( + "jaraco.abode.client.Client.set_setting", + side_effect=AbodeException((2, "Request failed")), + ), + pytest.raises(HomeAssistantError) as exc_info, + ): + await hass.services.async_call( + DOMAIN, + "change_setting", + {"setting": "confirm_snd", "value": "loud"}, + blocking=True, + ) + + assert exc_info.value.translation_key == "change_setting_failed" + assert exc_info.value.translation_placeholders == {"error": "(2, 'Request failed')"} + + async def test_add_unique_id(hass: HomeAssistant) -> None: """Test unique_id is set to Abode username.""" mock_entry = await setup_platform(hass, ALARM_DOMAIN)