Handle MissingSerial during OpenEVSE entry setup (#183105)

This commit is contained in:
Chris
2026-09-25 15:35:36 +02:00
committed by GitHub
parent c2eda825c9
commit ca1c2b7e6a
2 changed files with 19 additions and 2 deletions
@@ -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()
+16 -1
View File
@@ -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