From 789d4e2e501355836b50ca735039816adf83722e Mon Sep 17 00:00:00 2001 From: xZetsubou Date: Sat, 21 Oct 2023 07:00:20 +0300 Subject: [PATCH] Add gateway_gwId to discovered sub devices. and prevent non local subdevices --- custom_components/localtuya/config_flow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/localtuya/config_flow.py b/custom_components/localtuya/config_flow.py index eb42149d9..a886dc994 100644 --- a/custom_components/localtuya/config_flow.py +++ b/custom_components/localtuya/config_flow.py @@ -186,15 +186,16 @@ def mergeDevicesList(devList: dict, cloudList: dict, addSubDevices=True) -> dict else: # Create a data for sub_device [cloud and local gateway] to merge it with discovered devices. if len(gateway) > 0: - local_GW = devList[gateway[0].get(CONF_ID)] + local_GW: dict = devList[gateway[0].get(CONF_ID)] else: # If we can't find the gateway we will pull data without local "ip" - local_GW = cloudList[_devID] + continue dev_data = { _devID: { CONF_TUYA_IP: local_GW.get(CONF_TUYA_IP), CONF_TUYA_GWID: _devID, CONF_TUYA_VERSION: local_GW.get(CONF_TUYA_VERSION, "auto"), CONF_NODE_ID: cloudList[_devID].get(CONF_NODE_ID, None), + "gateway_gwId": local_GW.get(CONF_TUYA_GWID), } } newList.update(dev_data)