mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Handle monitoring failure for Satel Integra (#181548)
Co-authored-by: Erwin Douna <e.douna@gmail.com>
This commit is contained in:
co-authored by
Erwin Douna
parent
726741e4ca
commit
c682c23b2d
@@ -6,6 +6,7 @@ from satel_integra import AsyncSatel
|
||||
from satel_integra.exceptions import (
|
||||
SatelConnectFailedError,
|
||||
SatelConnectionInitializationError,
|
||||
SatelMonitoringStartError,
|
||||
SatelPanelBusyError,
|
||||
)
|
||||
|
||||
@@ -107,7 +108,13 @@ class SatelClient:
|
||||
output_changed_callback=outputs_update_callback,
|
||||
)
|
||||
|
||||
await self.controller.start(enable_monitoring=True)
|
||||
try:
|
||||
await self.controller.start(enable_monitoring=True)
|
||||
except SatelMonitoringStartError as ex:
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="monitoring_start_failed",
|
||||
) from ex
|
||||
|
||||
async def async_close(self) -> None:
|
||||
"""Close the connection."""
|
||||
|
||||
@@ -206,6 +206,9 @@
|
||||
"missing_output_access_code": {
|
||||
"message": "Cannot control switchable outputs because no user code is configured for this Satel Integra entry. Configure a code in the integration options to enable output control."
|
||||
},
|
||||
"monitoring_start_failed": {
|
||||
"message": "Connected to the alarm panel, but the panel did not confirm the request to start sending status updates."
|
||||
},
|
||||
"panel_busy": {
|
||||
"message": "[%key:component::satel_integra::config::error::panel_busy%]"
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import pytest
|
||||
from satel_integra import (
|
||||
SatelConnectFailedError,
|
||||
SatelConnectionInitializationError,
|
||||
SatelMonitoringStartError,
|
||||
SatelPanelBusyError,
|
||||
)
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
@@ -243,3 +244,21 @@ async def test_setup_exceptions(
|
||||
mock_satel.connect.side_effect = exception
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
assert mock_config_entry.state is expected_state
|
||||
|
||||
|
||||
async def test_monitoring_start_error(
|
||||
hass: HomeAssistant,
|
||||
mock_satel: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test setup is retried when monitoring fails to start."""
|
||||
mock_satel.start.side_effect = SatelMonitoringStartError
|
||||
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
assert mock_config_entry.reason == (
|
||||
"Connected to the alarm panel, but the panel did not confirm the request to start sending status updates"
|
||||
)
|
||||
mock_satel.start.assert_awaited_once_with(enable_monitoring=True)
|
||||
mock_satel.read_panel_info.assert_not_awaited()
|
||||
|
||||
Reference in New Issue
Block a user