diff --git a/homeassistant/components/satel_integra/__init__.py b/homeassistant/components/satel_integra/__init__.py index 69ed6339f29e..5705b826052e 100644 --- a/homeassistant/components/satel_integra/__init__.py +++ b/homeassistant/components/satel_integra/__init__.py @@ -2,6 +2,8 @@ import logging +from satel_integra import SatelIntegraError + from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.core import Event, HomeAssistant, callback from homeassistant.helpers import config_validation as cv, device_registry as dr @@ -84,11 +86,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: SatelConfigEntry) -> boo hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_close_connection) ) + try: + panel_info = await client.controller.read_panel_info() + except SatelIntegraError: + _LOGGER.warning("Unable to read Satel panel information", exc_info=True) + panel_info = None + device_registry = dr.async_get(hass) device_registry.async_get_or_create( config_entry_id=entry.entry_id, identifiers={(DOMAIN, entry.entry_id)}, manufacturer="Satel", + model=panel_info.model.name if panel_info and panel_info.model else None, + sw_version=str(panel_info.firmware) if panel_info else None, ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/tests/components/satel_integra/conftest.py b/tests/components/satel_integra/conftest.py index 96ae6637134a..c55a8a6f055a 100644 --- a/tests/components/satel_integra/conftest.py +++ b/tests/components/satel_integra/conftest.py @@ -5,6 +5,7 @@ from copy import deepcopy from unittest.mock import AsyncMock, MagicMock, patch import pytest +from satel_integra import SatelFirmwareVersion, SatelPanelInfo, SatelPanelModel from homeassistant.components.satel_integra.config_flow import SatelConfigFlow from homeassistant.components.satel_integra.const import DOMAIN @@ -64,6 +65,17 @@ def mock_satel() -> Generator[AsyncMock]: client.violated_zones = [] client.connect = AsyncMock(return_value=True) + client.read_panel_info = AsyncMock( + return_value=SatelPanelInfo( + type_code=2, + model=SatelPanelModel("INTEGRA 64"), + firmware=SatelFirmwareVersion( + version="1.24", release_date="2025-03-12" + ), + language_code=0, + settings_stored_in_flash=True, + ) + ) client.read_temperature = AsyncMock(return_value=21.5) client.read_temperatures = AsyncMock(return_value={1: 21.5}) client.set_output = AsyncMock() diff --git a/tests/components/satel_integra/snapshots/test_init.ambr b/tests/components/satel_integra/snapshots/test_init.ambr index a88c6922cc6b..c150f1550ca9 100644 --- a/tests/components/satel_integra/snapshots/test_init.ambr +++ b/tests/components/satel_integra/snapshots/test_init.ambr @@ -20,12 +20,12 @@ 'labels': set({ }), 'manufacturer': 'Satel', - 'model': None, + 'model': 'INTEGRA 64', 'model_id': None, 'name': '192.168.0.2', 'name_by_user': None, 'serial_number': None, - 'sw_version': None, + 'sw_version': '1.24 (2025-03-12)', 'via_device_id': None, }) # --- diff --git a/tests/components/satel_integra/test_init.py b/tests/components/satel_integra/test_init.py index 8fcd61b5db7e..8bb43d342788 100644 --- a/tests/components/satel_integra/test_init.py +++ b/tests/components/satel_integra/test_init.py @@ -8,6 +8,7 @@ from satel_integra import ( SatelConnectFailedError, SatelConnectionInitializationError, SatelPanelBusyError, + SatelUnexpectedResponseError, ) from syrupy.assertion import SnapshotAssertion @@ -222,6 +223,27 @@ async def test_parent_device_exists( (DOMAIN, MOCK_ENTRY_ID), mock_config_entry.entry_id ) assert device_entry == snapshot(name="parent-device") + mock_satel.read_panel_info.assert_awaited_once_with() + + +async def test_panel_info_read_error( + hass: HomeAssistant, + mock_satel: AsyncMock, + device_registry: DeviceRegistry, + mock_config_entry: MockConfigEntry, +) -> None: + """Test a panel information read error does not prevent setup.""" + mock_satel.read_panel_info.side_effect = SatelUnexpectedResponseError + + await setup_integration(hass, mock_config_entry) + + assert mock_config_entry.state is ConfigEntryState.LOADED + device_entry = device_registry.async_get_device_by_identifier( + (DOMAIN, MOCK_ENTRY_ID), mock_config_entry.entry_id + ) + assert device_entry is not None + assert device_entry.model is None + assert device_entry.sw_version is None @pytest.mark.parametrize(