From b049ad97f20b7d9cc90c44723992c634d0d1644d Mon Sep 17 00:00:00 2001 From: Arie Catsman Date: Sat, 24 Aug 2024 15:40:31 +0000 Subject: [PATCH 1/2] Include all enphase_envoy devices in async_remove_config_entry_device --- homeassistant/components/enphase_envoy/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/homeassistant/components/enphase_envoy/__init__.py b/homeassistant/components/enphase_envoy/__init__.py index f6438230789d6d..801ae9b13d56fc 100644 --- a/homeassistant/components/enphase_envoy/__init__.py +++ b/homeassistant/components/enphase_envoy/__init__.py @@ -64,4 +64,11 @@ async def async_remove_config_entry_device( for inverter in envoy_data.inverters: if str(inverter) in dev_ids: return False + if envoy_data and envoy_data.encharge_inventory: + for encharge in envoy_data.encharge_inventory: + if str(encharge) in dev_ids: + return False + if envoy_data and envoy_data.enpower: + if str(envoy_data.enpower.serial_number) in dev_ids: + return False return True From ffb0e732423d9689a715bcd703e8ab5390457768 Mon Sep 17 00:00:00 2001 From: Arie Catsman Date: Sat, 7 Sep 2024 08:01:35 +0000 Subject: [PATCH 2/2] refactor if tests --- .../components/enphase_envoy/__init__.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/enphase_envoy/__init__.py b/homeassistant/components/enphase_envoy/__init__.py index 801ae9b13d56fc..ba590fa0337beb 100644 --- a/homeassistant/components/enphase_envoy/__init__.py +++ b/homeassistant/components/enphase_envoy/__init__.py @@ -60,15 +60,16 @@ async def async_remove_config_entry_device( envoy_serial_num = config_entry.unique_id if envoy_serial_num in dev_ids: return False - if envoy_data and envoy_data.inverters: - for inverter in envoy_data.inverters: - if str(inverter) in dev_ids: + if envoy_data: + if envoy_data.inverters: + for inverter in envoy_data.inverters: + if str(inverter) in dev_ids: + return False + if envoy_data.encharge_inventory: + for encharge in envoy_data.encharge_inventory: + if str(encharge) in dev_ids: + return False + if envoy_data.enpower: + if str(envoy_data.enpower.serial_number) in dev_ids: return False - if envoy_data and envoy_data.encharge_inventory: - for encharge in envoy_data.encharge_inventory: - if str(encharge) in dev_ids: - return False - if envoy_data and envoy_data.enpower: - if str(envoy_data.enpower.serial_number) in dev_ids: - return False return True