From ca1c2b7e6ae01e93975332dff6a79366de29718b Mon Sep 17 00:00:00 2001 From: Chris <1105672+firstof9@users.noreply.github.com> Date: Fri, 25 Sep 2026 06:35:36 -0700 Subject: [PATCH] Handle MissingSerial during OpenEVSE entry setup (#183105) --- homeassistant/components/openevse/__init__.py | 4 +++- tests/components/openevse/test_init.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/openevse/__init__.py b/homeassistant/components/openevse/__init__.py index daf12c5bc8dd..6e79c6195d60 100644 --- a/homeassistant/components/openevse/__init__.py +++ b/homeassistant/components/openevse/__init__.py @@ -1,7 +1,7 @@ """The OpenEVSE integration.""" from openevsehttp.__main__ import OpenEVSE -from openevsehttp.exceptions import AuthenticationError +from openevsehttp.exceptions import AuthenticationError, MissingSerial from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant @@ -42,6 +42,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenEVSEConfigEntry) -> translation_domain=DOMAIN, translation_key="authentication_error", ) from ex + except MissingSerial: + pass coordinator = OpenEVSEDataUpdateCoordinator(hass, entry, charger) await coordinator.async_config_entry_first_refresh() diff --git a/tests/components/openevse/test_init.py b/tests/components/openevse/test_init.py index a0326dbf598f..24b33aec2319 100644 --- a/tests/components/openevse/test_init.py +++ b/tests/components/openevse/test_init.py @@ -2,7 +2,7 @@ from unittest.mock import MagicMock -from openevsehttp.exceptions import AuthenticationError +from openevsehttp.exceptions import AuthenticationError, MissingSerial from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState from homeassistant.core import HomeAssistant @@ -84,3 +84,18 @@ async def test_unload_entry( await hass.async_block_till_done() assert mock_config_entry.state is ConfigEntryState.NOT_LOADED + + +async def test_setup_entry_missing_serial( + hass: HomeAssistant, + mock_config_entry: MockConfigEntry, + mock_charger: MagicMock, +) -> None: + """Test setup entry succeeds when serial number is missing.""" + mock_charger.test_and_get.side_effect = MissingSerial + + mock_config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + assert mock_config_entry.state is ConfigEntryState.LOADED