From bfc3d3be764123adb147d39d73b87c2e9e9d9673 Mon Sep 17 00:00:00 2001 From: Rob Bierbooms Date: Tue, 3 Nov 2020 23:01:52 +0100 Subject: [PATCH] Filter rfxtrx replace devices in option flow on existing config entry (#42800) * Fix function _can_replace_device * Rearrange --- homeassistant/components/rfxtrx/config_flow.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/rfxtrx/config_flow.py b/homeassistant/components/rfxtrx/config_flow.py index 624b7ade69d..f81fdde3c4c 100644 --- a/homeassistant/components/rfxtrx/config_flow.py +++ b/homeassistant/components/rfxtrx/config_flow.py @@ -360,13 +360,17 @@ class OptionsFlow(config_entries.OptionsFlow): """Check if device can be replaced with selected device.""" device_data = self._get_device_data(entry_id) event_code = device_data[CONF_EVENT_CODE] - rfx_obj = get_rfx_object(event_code) - if ( - rfx_obj.device.packettype == self._selected_device_object.device.packettype - and rfx_obj.device.subtype == self._selected_device_object.device.subtype - and self._selected_device_event_code != event_code - ): - return True + + if event_code is not None: + rfx_obj = get_rfx_object(event_code) + if ( + rfx_obj.device.packettype + == self._selected_device_object.device.packettype + and rfx_obj.device.subtype + == self._selected_device_object.device.subtype + and self._selected_device_event_code != event_code + ): + return True return False