Abode: report change setting failures (#179756)

This commit is contained in:
Oluwatobi Mustapha
2026-08-24 23:05:32 +02:00
committed by GitHub
parent 381e80c9ac
commit e54540ea06
3 changed files with 36 additions and 3 deletions
+7 -3
View File
@@ -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:
@@ -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.",
+24
View File
@@ -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)