From 48c1005e2cff3d1c54a679d7aaa8cd1c5a36c867 Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Fri, 27 Oct 2023 21:56:30 +0200 Subject: [PATCH] Sonoff SNZB-02 gets connected as SONOFF Temp/Humi and is a Motion --- Modules/pluginModels.py | 22 ++++++++++++++++++---- Modules/zclClusterHelpers.py | 14 ++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Modules/pluginModels.py b/Modules/pluginModels.py index d7401c3b9..c94b55a8c 100644 --- a/Modules/pluginModels.py +++ b/Modules/pluginModels.py @@ -34,12 +34,11 @@ def check_found_plugin_model( self, model, manufacturer_name=None, manufacturer_ if "Model" in x and model not in x["Model"]: continue if ( - "Manufacturer" in x and x["Manufacturer"] and manufacturer_name not in x["Manufacturer"] - or "ManufId" in x and x["ManufId"] and manufacturer_code not in x["ManufId"] + ( "Manufacturer" in x and x["Manufacturer"] and manufacturer_name not in x["Manufacturer"] ) + or ( "ManufId" in x and x["ManufId"] and manufacturer_code not in x["ManufId"]) + or ( "DeviceID" in x and x["DeviceID"] and device_id not in x["DeviceID"] ) ): continue - if "DeviceID" in x and x["DeviceID"] and device_id not in x["DeviceID"]: - continue self.log.logging( "Pairing", "Log", "check_found_plugin_model - Found %s" % x) @@ -240,5 +239,20 @@ def check_found_plugin_model( self, model, manufacturer_name=None, manufacturer_ "ManufId": [], "PluginModelName": "TS0601-_TZE200_dzuqwsyg",}, + # SONOFF 66666 'Temperature and humidity sensor',: + { + "Model": ["66666",], + "Manufacturer": "eWeLink", + "DeviceID": "0302", + "PluginModelName": "66666-temphumi.json" + }, + + # SONOFF 66666 'Motion' + { + "Model": ["66666",], + "Manufacturer": "eWeLink", + "DeviceID": "0402", + "PluginModelName": "66666-motion.json" + } ] diff --git a/Modules/zclClusterHelpers.py b/Modules/zclClusterHelpers.py index 8f057e931..4ea66372a 100644 --- a/Modules/zclClusterHelpers.py +++ b/Modules/zclClusterHelpers.py @@ -220,24 +220,26 @@ def _upd_data_strut_based_on_model(self, MsgSrcAddr, modelName, inital_ep): def _build_model_name( self, nwkid, modelName): - manufacturer_name = self.ListOfDevices[nwkid]["Manufacturer Name"] if "Manufacturer Name" in self.ListOfDevices[nwkid] else "" - manuf_code = self.ListOfDevices[nwkid]["Manufacturer"] if "Manufacturer" in self.ListOfDevices[nwkid] else "" + manufacturer_name = self.ListOfDevices[nwkid].get("Manufacturer Name", "") + manuf_code = self.ListOfDevices[nwkid].get("Manufacturer", "") + zdevice_id = self.ListOfDevices[nwkid].get("ZDeviceID", None) + if modelName in ( '66666', ): + # https://github.com/Koenkk/zigbee2mqtt/issues/4338 + return check_found_plugin_model( self, modelName, manufacturer_name=manufacturer_name, manufacturer_code=manuf_code, device_id=zdevice_id) # Try to check if the Model name is in the DeviceConf list ( optimised devices) if modelName + '-' + manufacturer_name in self.DeviceConf: return modelName + '-' + manufacturer_name - + if modelName + manufacturer_name in self.DeviceConf: return modelName + manufacturer_name - + # If not found, let see if the model name can be extracted from the (ModelName, ManufacturerName) tuple set in the Conf file as Identifier plugin_identifier = plugin_self_identifier( self, modelName, manufacturer_name) if plugin_identifier: return plugin_identifier - zdevice_id = self.ListOfDevices[nwkid]["ZDeviceID"] if "ZDeviceID" in self.ListOfDevices[nwkid] and self.ListOfDevices[nwkid]["ZDeviceID"] else None - return check_found_plugin_model( self, modelName, manufacturer_name=manufacturer_name, manufacturer_code=manuf_code, device_id=zdevice_id)