diff --git a/custom_components/solaredge_modbus_multi/__init__.py b/custom_components/solaredge_modbus_multi/__init__.py index 2c927e07..5b806d81 100644 --- a/custom_components/solaredge_modbus_multi/__init__.py +++ b/custom_components/solaredge_modbus_multi/__init__.py @@ -242,6 +242,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.options.get(CONF_SCAN_INTERVAL, ConfDefaultInt.SCAN_INTERVAL), ) + # Drop the entry-independent issue ID used by earlier versions. + ir.async_delete_issue(hass, DOMAIN, "check_configuration") + ir.async_delete_issue(hass, DOMAIN, "deprecated_keep_modbus_open") + hass.data[DOMAIN][entry.entry_id] = { "hub": solaredge_hub, "coordinator": coordinator, @@ -390,7 +394,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> ir.async_create_issue( hass, DOMAIN, - "deprecated_keep_modbus_open", + f"deprecated_keep_modbus_open_{config_entry.entry_id}", is_fixable=False, severity=ir.IssueSeverity.WARNING, translation_key="deprecated_keep_modbus_open", diff --git a/custom_components/solaredge_modbus_multi/hub.py b/custom_components/solaredge_modbus_multi/hub.py index 28c03ce8..0d1c98d2 100644 --- a/custom_components/solaredge_modbus_multi/hub.py +++ b/custom_components/solaredge_modbus_multi/hub.py @@ -521,7 +521,7 @@ async def async_refresh_modbus_data(self) -> bool: ir.async_create_issue( self._hass, DOMAIN, - "check_configuration", + f"check_configuration_{self._entry_id}", is_fixable=True, severity=ir.IssueSeverity.ERROR, translation_key="check_configuration", @@ -531,7 +531,9 @@ async def async_refresh_modbus_data(self) -> bool: f"Coordinator setup timed out after {self.coordinator_timeout} seconds." ) from err - ir.async_delete_issue(self._hass, DOMAIN, "check_configuration") + ir.async_delete_issue( + self._hass, DOMAIN, f"check_configuration_{self._entry_id}" + ) return True diff --git a/custom_components/solaredge_modbus_multi/repairs.py b/custom_components/solaredge_modbus_multi/repairs.py index 98017635..1e008d10 100644 --- a/custom_components/solaredge_modbus_multi/repairs.py +++ b/custom_components/solaredge_modbus_multi/repairs.py @@ -164,7 +164,7 @@ async def async_create_fix_flow( entry_id = cast(str, data["entry_id"]) if (entry := hass.config_entries.async_get_entry(entry_id)) is not None: - if issue_id == "check_configuration": + if issue_id.startswith("check_configuration_"): return CheckConfigurationRepairFlow(entry) if issue_id.startswith("detect_timeout_gpc_"): diff --git a/tests/test_repairs.py b/tests/test_repairs.py index ce3b94cf..9f39460a 100644 --- a/tests/test_repairs.py +++ b/tests/test_repairs.py @@ -3,10 +3,13 @@ from types import SimpleNamespace from homeassistant.data_entry_flow import FlowResultType +from pytest_homeassistant_custom_component.common import MockConfigEntry from custom_components.solaredge_modbus_multi.const import DOMAIN from custom_components.solaredge_modbus_multi.repairs import ( + CheckConfigurationRepairFlow, RetryFeatureDetectionRepairFlow, + async_create_fix_flow, ) @@ -70,3 +73,15 @@ async def test_unknown_inverter_unit_id_is_a_no_op(hass): assert inverter.global_power_control is False assert result["type"] == FlowResultType.CREATE_ENTRY + + +async def test_check_configuration_issue_routes_to_its_flow(hass): + """Test the per-entry check_configuration issue ID opens its repair flow.""" + entry = MockConfigEntry(domain=DOMAIN) + entry.add_to_hass(hass) + + flow = await async_create_fix_flow( + hass, f"check_configuration_{entry.entry_id}", {"entry_id": entry.entry_id} + ) + + assert isinstance(flow, CheckConfigurationRepairFlow)