From b6e7bf65d78e156404304894c22c4b61f1f07850 Mon Sep 17 00:00:00 2001 From: Manuel Pietschmann Date: Tue, 6 Apr 2021 17:35:40 +0200 Subject: [PATCH 1/4] Put R_GetProductId() and isTuyaManufacturerName() in own module --- database.cpp | 1 + de_web.pro | 2 + de_web_plugin.cpp | 1 + light_node.cpp | 1 + product_match.cpp | 184 ++++++++++++++++++++++++++++++++++++++++++++ product_match.h | 21 +++++ resource.cpp | 153 ------------------------------------ resource.h | 1 - rest_lights.cpp | 1 + rest_sensors.cpp | 1 + sensor.cpp | 2 +- tuya.cpp | 18 +---- tuya.h | 1 - window_covering.cpp | 1 + 14 files changed, 215 insertions(+), 173 deletions(-) create mode 100644 product_match.cpp create mode 100644 product_match.h diff --git a/database.cpp b/database.cpp index 18008c5ded..6519d315a0 100644 --- a/database.cpp +++ b/database.cpp @@ -17,6 +17,7 @@ #include "deconz/dbg_trace.h" #include "gateway.h" #include "json.h" +#include "product_match.h" static const char *pragmaUserVersion = "PRAGMA user_version"; static const char *pragmaPageCount = "PRAGMA page_count"; diff --git a/de_web.pro b/de_web.pro index 7590c768d4..f9db5bc0cd 100644 --- a/de_web.pro +++ b/de_web.pro @@ -108,6 +108,7 @@ HEADERS = bindings.h \ light_node.h \ poll_control.h \ poll_manager.h \ + product_match.h \ read_files.h \ resource.h \ resourcelinks.h \ @@ -150,6 +151,7 @@ SOURCES = air_quality.cpp \ light_node.cpp \ poll_control.cpp \ poll_manager.cpp \ + product_match.cpp \ read_files.cpp \ resource.cpp \ resourcelinks.cpp \ diff --git a/de_web_plugin.cpp b/de_web_plugin.cpp index 2bef4c308d..216299ecb8 100644 --- a/de_web_plugin.cpp +++ b/de_web_plugin.cpp @@ -41,6 +41,7 @@ #include "json.h" #include "poll_control.h" #include "poll_manager.h" +#include "product_match.h" #include "rest_devices.h" #include "read_files.h" #ifdef ARCH_ARM diff --git a/light_node.cpp b/light_node.cpp index 6a84ac6229..dd8dc5c46e 100644 --- a/light_node.cpp +++ b/light_node.cpp @@ -9,6 +9,7 @@ */ #include "de_web_plugin_private.h" +#include "product_match.h" /*! Constructor. */ diff --git a/product_match.cpp b/product_match.cpp new file mode 100644 index 0000000000..1261c6dbf0 --- /dev/null +++ b/product_match.cpp @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2021 dresden elektronik ingenieurtechnik gmbh. + * All rights reserved. + * + * The software in this package is published under the terms of the BSD + * style license a copy of which has been included with this distribution in + * the LICENSE.txt file. + * + */ + +#include +#include + +#include "product_match.h" +#include "resource.h" + +/*! The product map is a helper to map Basic Cluster manufacturer name and modelid + to human readable product identifiers like marketing string or the model no. as printed on the product package. + + In case of Tuya multiple entries may refer to the same device, so in matching code + it's best to match against the \c productId. + + Example: + + if (R_GetProductId(sensor) == QLatin1String("SEA801-ZIGBEE TRV")) + { + } + + Note: this will later on be replaced with the data from DDF files. +*/ +struct ProductMap +{ + const char *zmanufacturerName; + const char *zmodelId; + const char *manufacturer; + // a common product identifier even if multipe branded versions exist + const char *commonProductId; +}; + +static const ProductMap products[] = +{ + // Prefix signification + // -------------------- + // Tuya_THD : thermostat device using Tuya cluster + // Tuya_COVD : covering device using Tuya cluster + // Tuya_RPT : Repeater + + // Tuya Thermostat / TRV + {"_TYST11_zuhszj9s", "uhszj9s", "HiHome", "Tuya_THD WZB-TRVL TRV"}, + {"_TYST11_KGbxAXL2", "GbxAXL2", "Saswell", "Tuya_THD SEA801-ZIGBEE TRV"}, + {"_TYST11_c88teujp", "88teujp", "Saswell", "Tuya_THD SEA801-ZIGBEE TRV"}, + {"_TZE200_c88teujp", "TS0601", "Saswell", "Tuya_THD SEA801-ZIGBEE TRV"}, + {"_TYST11_ckud7u2l", "kud7u2l", "Tuya", "Tuya_THD HY369 TRV"}, + {"_TZE200_ckud7u2l", "TS0601", "Tuya", "Tuya_THD HY369 TRV"}, + {"_TZE200_ywdxldoj", "TS0601", "MOES/tuya", "Tuya_THD HY368 TRV"}, + {"_TZE200_aoclfnxz", "TS0601", "Moes", "Tuya_THD BTH-002 Thermostat"}, + {"_TYST11_jeaxp72v", "eaxp72v", "Essentials", "Tuya_THD Essentials TRV"}, + {"_TYST11_kfvq6avy", "fvq6avy", "Revolt", "Tuya_THD NX-4911-675 TRV"}, + {"_TZE200_kfvq6avy", "TS0601", "Revolt", "Tuya_THD NX-4911-675 TRV"}, + {"_TYST11_zivfvd7h", "ivfvd7h", "Siterwell", "Tuya_THD GS361A-H04 TRV"}, + {"_TZE200_zivfvd7h", "TS0601", "Siterwell", "Tuya_THD GS361A-H04 TRV"}, + {"_TYST11_yw7cahqs", "w7cahqs", "Hama", "Tuya_THD Smart radiator TRV"}, + + // Tuya Covering + {"_TYST11_wmcdj3aq", "mcdj3aq", "Zemismart", "Tuya_COVD ZM25TQ"}, + {"_TZE200_wmcdj3aq", "TS0601", "Zemismart", "Tuya_COVD ZM25TQ"}, + {"_TZE200_fzo2pocs", "TS0601", "Zemismart", "Tuya_COVD ZM25TQ"}, + {"_TYST11_xu1rkty3", "u1rkty3", "Smart Home", "Tuya_COVD DT82LEMA-1.2N"}, + {"_TZE200_xuzcvlku", "TS0601", "Zemismart", "Tuya_COVD M515EGB"}, + {"_TZE200_zah67ekd", "TS0601", "MoesHouse / Livolo", "Tuya_COVD AM43-0.45-40"}, + {"_TZE200_nogaemzt", "TS0601", "Tuya", "Tuya_COVD YS-MT750"}, + {"_TZE200_zpzndjez", "TS0601", "Tuya", "Tuya_COVD DS82"}, + {"_TZE200_cowvfni3", "TS0601", "Zemismart", "Tuya_COVD ZM79E-DT"}, + {"_TZE200_5zbp6j0u", "TS0601", "Tuya/Zemismart", "Tuya_COVD DT82LEMA-1.2N"}, + {"_TZE200_fdtjuw7u", "TS0601", "Yushun", "Tuya_COVD YS-MT750"}, + {"_TZE200_bqcqqjpb", "TS0601", "Yushun", "Tuya_COVD YS-MT750"}, + {"_TZE200_nueqqe6k", "TS0601", "Zemismart", "Tuya_COVD M515EGB"}, + + // Tuya covering not using tuya cluster but need reversing + {"_TZ3000_egq7y6pr", "TS130F", "Lonsonho", "11830304 Switch"}, + {"_TZ3000_xzqbrqk1", "TS130F", "Lonsonho", "Zigbee curtain switch"}, // https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3757#issuecomment-776201454 + {"_TZ3000_ltiqubue", "TS130F", "Tuya", "Zigbee curtain switch"}, + {"_TZ3000_vd43bbfq", "TS130F", "Tuya", "QS-Zigbee-C01 Module"}, // Curtain module QS-Zigbee-C01 + + // Other + {"_TYST11_d0yu2xgi", "0yu2xgi", "NEO/Tuya", "NAS-AB02B0 Siren"}, + {"_TZE200_d0yu2xgi", "TS0601", "NEO/Tuya", "NAS-AB02B0 Siren"}, + {"_TZ3000_m0vaazab", "TS0207", "Tuya", "Tuya_RPT Repeater"}, + + {nullptr, nullptr, nullptr, nullptr} +}; + +/*! Returns the product identifier for a matching Basic Cluster manufacturer name. */ +static QLatin1String productIdForManufacturerName(const QString &manufacturerName, const ProductMap *mapIter) +{ + Q_ASSERT(mapIter); + + for (; mapIter->commonProductId != nullptr; mapIter++) + { + if (manufacturerName == QLatin1String(mapIter->zmanufacturerName)) + { + return QLatin1String(mapIter->commonProductId); + } + } + + return QLatin1String(""); +} + +/*! Returns the product identifier for a resource. */ +const QString R_GetProductId(Resource *resource) +{ + DBG_Assert(resource); + + + if (!resource) + { + return { }; + } + + auto *productId = resource->item(RAttrProductId); + + if (productId) + { + return productId->toString(); + } + + const auto *manufacturerName = resource->item(RAttrManufacturerName); + const auto *modelId = resource->item(RAttrModelId); + + // Need manufacturerName + if (!manufacturerName) + { + return { }; + } + + //Tuya don't need modelId + if (isTuyaManufacturerName(manufacturerName->toString())) + { + // for Tuya devices match against manufacturer name + const auto productIdStr = productIdForManufacturerName(manufacturerName->toString(), products); + if (productIdStr.size() > 0) + { + productId = resource->addItem(DataTypeString, RAttrProductId); + DBG_Assert(productId); + productId->setValue(QString(productIdStr)); + productId->setIsPublic(false); // not ready for public + return productId->toString(); + } + else + { + // Fallback + // manufacturer name is the most unique identifier for Tuya + if (DBG_IsEnabled(DBG_INFO_L2)) + { + DBG_Printf(DBG_INFO_L2, "No Tuya productId entry found for manufacturername: %s\n", qPrintable(manufacturerName->toString())); + } + + return manufacturerName->toString(); + } + } + + if (modelId) + { + return modelId->toString(); + } + + return { }; +} + +/*! Returns true if the \p manufacturer name referes to a Tuya device. */ +bool isTuyaManufacturerName(const QString &manufacturer) +{ + return manufacturer.startsWith(QLatin1String("_T")) && // quick check for performance + std::regex_match(qPrintable(manufacturer), std::regex("_T[A-Z][A-Z0-9]{4}_[a-z0-9]{8}")); +} + +// Tests for Tuya manufacturer name +/* + Q_ASSERT(isTuyaManufacturerName("_TZ3000_bi6lpsew")); + Q_ASSERT(isTuyaManufacturerName("_TYZB02_key8kk7r")); + Q_ASSERT(isTuyaManufacturerName("_TYST11_ckud7u2l")); + Q_ASSERT(isTuyaManufacturerName("_TYZB02_keyjqthh")); + Q_ASSERT(!isTuyaManufacturerName("lumi.sensor_switch.aq2")); +*/ diff --git a/product_match.h b/product_match.h new file mode 100644 index 0000000000..ebe6abde0c --- /dev/null +++ b/product_match.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2021 dresden elektronik ingenieurtechnik gmbh. + * All rights reserved. + * + * The software in this package is published under the terms of the BSD + * style license a copy of which has been included with this distribution in + * the LICENSE.txt file. + * + */ + +#ifndef PRODUCT_MATCH_H +#define PRODUCT_MATCH_H + +#include + +class Resource; + +const QString R_GetProductId(Resource *resource); +bool isTuyaManufacturerName(const QString &manufacturer); + +#endif // PRODUCT_MATCH_H diff --git a/resource.cpp b/resource.cpp index a814ac2901..d1d33eef8b 100644 --- a/resource.cpp +++ b/resource.cpp @@ -450,159 +450,6 @@ bool R_HasFlags(const ResourceItem *item, qint64 flags) return false; } -/*! The product map is a helper to map Basic Cluster manufacturer name and modelid - to human readable product identifiers like marketing string or the model no. as printed on the product package. - - In case of Tuya multiple entries may refer to the same device, so in matching code - it's best to match against the \c productId. - - Example: - - if (R_GetProductId(sensor) == QLatin1String("SEA801-ZIGBEE TRV")) - { - } - - Note: this will later on be replaced with the data from DDF files. -*/ -struct ProductMap -{ - const char *zmanufacturerName; - const char *zmodelId; - const char *manufacturer; - // a common product identifier even if multipe branded versions exist - const char *commonProductId; -}; - -static const ProductMap products[] = -{ - // Prefix signification - // -------------------- - // Tuya_THD : thermostat device using Tuya cluster - // Tuya_COVD : covering device using Tuya cluster - // Tuya_RPT : Repeater - - // Tuya Thermostat / TRV - {"_TYST11_zuhszj9s", "uhszj9s", "HiHome", "Tuya_THD WZB-TRVL TRV"}, - {"_TYST11_KGbxAXL2", "GbxAXL2", "Saswell", "Tuya_THD SEA801-ZIGBEE TRV"}, - {"_TYST11_c88teujp", "88teujp", "Saswell", "Tuya_THD SEA801-ZIGBEE TRV"}, - {"_TZE200_c88teujp", "TS0601", "Saswell", "Tuya_THD SEA801-ZIGBEE TRV"}, - {"_TYST11_ckud7u2l", "kud7u2l", "Tuya", "Tuya_THD HY369 TRV"}, - {"_TZE200_ckud7u2l", "TS0601", "Tuya", "Tuya_THD HY369 TRV"}, - {"_TZE200_ywdxldoj", "TS0601", "MOES/tuya", "Tuya_THD HY368 TRV"}, - {"_TZE200_aoclfnxz", "TS0601", "Moes", "Tuya_THD BTH-002 Thermostat"}, - {"_TYST11_jeaxp72v", "eaxp72v", "Essentials", "Tuya_THD Essentials TRV"}, - {"_TYST11_kfvq6avy", "fvq6avy", "Revolt", "Tuya_THD NX-4911-675 TRV"}, - {"_TZE200_kfvq6avy", "TS0601", "Revolt", "Tuya_THD NX-4911-675 TRV"}, - {"_TYST11_zivfvd7h", "ivfvd7h", "Siterwell", "Tuya_THD GS361A-H04 TRV"}, - {"_TZE200_zivfvd7h", "TS0601", "Siterwell", "Tuya_THD GS361A-H04 TRV"}, - {"_TYST11_yw7cahqs", "w7cahqs", "Hama", "Tuya_THD Smart radiator TRV"}, - - // Tuya Covering - {"_TYST11_wmcdj3aq", "mcdj3aq", "Zemismart", "Tuya_COVD ZM25TQ"}, - {"_TZE200_wmcdj3aq", "TS0601", "Zemismart", "Tuya_COVD ZM25TQ"}, - {"_TZE200_fzo2pocs", "TS0601", "Zemismart", "Tuya_COVD ZM25TQ"}, - {"_TYST11_xu1rkty3", "u1rkty3", "Smart Home", "Tuya_COVD DT82LEMA-1.2N"}, - {"_TZE200_xuzcvlku", "TS0601", "Zemismart", "Tuya_COVD M515EGB"}, - {"_TZE200_zah67ekd", "TS0601", "MoesHouse / Livolo", "Tuya_COVD AM43-0.45-40"}, - {"_TZE200_nogaemzt", "TS0601", "Tuya", "Tuya_COVD YS-MT750"}, - {"_TZE200_zpzndjez", "TS0601", "Tuya", "Tuya_COVD DS82"}, - {"_TZE200_cowvfni3", "TS0601", "Zemismart", "Tuya_COVD ZM79E-DT"}, - {"_TZE200_5zbp6j0u", "TS0601", "Tuya/Zemismart", "Tuya_COVD DT82LEMA-1.2N"}, - {"_TZE200_fdtjuw7u", "TS0601", "Yushun", "Tuya_COVD YS-MT750"}, - {"_TZE200_bqcqqjpb", "TS0601", "Yushun", "Tuya_COVD YS-MT750"}, - {"_TZE200_nueqqe6k", "TS0601", "Zemismart", "Tuya_COVD M515EGB"}, - - // Tuya covering not using tuya cluster but need reversing - {"_TZ3000_egq7y6pr", "TS130F", "Lonsonho", "11830304 Switch"}, - {"_TZ3000_xzqbrqk1", "TS130F", "Lonsonho", "Zigbee curtain switch"}, // https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3757#issuecomment-776201454 - {"_TZ3000_ltiqubue", "TS130F", "Tuya", "Zigbee curtain switch"}, - {"_TZ3000_vd43bbfq", "TS130F", "Tuya", "QS-Zigbee-C01 Module"}, // Curtain module QS-Zigbee-C01 - - // Other - {"_TYST11_d0yu2xgi", "0yu2xgi", "NEO/Tuya", "NAS-AB02B0 Siren"}, - {"_TZE200_d0yu2xgi", "TS0601", "NEO/Tuya", "NAS-AB02B0 Siren"}, - {"_TZ3000_m0vaazab", "TS0207", "Tuya", "Tuya_RPT Repeater"}, - - {nullptr, nullptr, nullptr, nullptr} -}; - -/*! Returns the product identifier for a matching Basic Cluster manufacturer name. */ -static QLatin1String productIdForManufacturerName(const QString &manufacturerName, const ProductMap *mapIter) -{ - Q_ASSERT(mapIter); - - for (; mapIter->commonProductId != nullptr; mapIter++) - { - if (manufacturerName == QLatin1String(mapIter->zmanufacturerName)) - { - return QLatin1String(mapIter->commonProductId); - } - } - - return QLatin1String(""); -} - -/*! Returns the product identifier for a resource. */ -const QString R_GetProductId(Resource *resource) -{ - DBG_Assert(resource); - - - if (!resource) - { - return rInvalidString; - } - - auto *productId = resource->item(RAttrProductId); - - if (productId) - { - return productId->toString(); - } - - const auto *manufacturerName = resource->item(RAttrManufacturerName); - const auto *modelId = resource->item(RAttrModelId); - - // Need manufacturerName - if (!manufacturerName) - { - return rInvalidString; - } - - //Tuya don't need modelId - if (isTuyaManufacturerName(manufacturerName->toString())) - { - // for Tuya devices match against manufacturer name - const auto productIdStr = productIdForManufacturerName(manufacturerName->toString(), products); - if (productIdStr.size() > 0) - { - productId = resource->addItem(DataTypeString, RAttrProductId); - DBG_Assert(productId); - productId->setValue(QString(productIdStr)); - productId->setIsPublic(false); // not ready for public - return productId->toString(); - } - else - { - // Fallback - // manufacturer name is the most unique identifier for Tuya - if (DBG_IsEnabled(DBG_INFO_L2)) - { - DBG_Printf(DBG_INFO_L2, "No Tuya productId entry found for manufacturername: %s\n", qPrintable(manufacturerName->toString())); - } - - return manufacturerName->toString(); - } - } - - if (modelId) - { - return modelId->toString(); - } - - return rInvalidString; -} - /*! Copy constructor. */ ResourceItem::ResourceItem(const ResourceItem &other) { diff --git a/resource.h b/resource.h index eadac3c384..57dbeafca3 100644 --- a/resource.h +++ b/resource.h @@ -347,6 +347,5 @@ bool R_SetFlags1(ResourceItem *item, qint64 flags, const char *strFlags); #define R_ClearFlags(item, flags) R_ClearFlags1(item, flags, #flags) bool R_ClearFlags1(ResourceItem *item, qint64 flags, const char *strFlags); bool R_HasFlags(const ResourceItem *item, qint64 flags); -const QString R_GetProductId(Resource *resource); #endif // RESOURCE_H diff --git a/rest_lights.cpp b/rest_lights.cpp index 660a7ebf82..d28501107b 100644 --- a/rest_lights.cpp +++ b/rest_lights.cpp @@ -18,6 +18,7 @@ #include "json.h" #include "connectivity.h" #include "colorspace.h" +#include "product_match.h" /*! Lights REST API broker. \param req - request data diff --git a/rest_sensors.cpp b/rest_sensors.cpp index 12161cd0f3..0a24ca4123 100644 --- a/rest_sensors.cpp +++ b/rest_sensors.cpp @@ -17,6 +17,7 @@ #include "de_web_plugin.h" #include "de_web_plugin_private.h" #include "json.h" +#include "product_match.h" /*! Sensors REST API broker. \param req - request data diff --git a/sensor.cpp b/sensor.cpp index bef0fdf0b7..2258d6e3d7 100644 --- a/sensor.cpp +++ b/sensor.cpp @@ -9,8 +9,8 @@ */ #include "sensor.h" -#include "tuya.h" #include "json.h" +#include "product_match.h" /*! Returns a fingerprint as JSON string. */ QString SensorFingerprint::toString() const diff --git a/tuya.cpp b/tuya.cpp index aac8a135f6..5f741744bb 100644 --- a/tuya.cpp +++ b/tuya.cpp @@ -5,10 +5,10 @@ * */ -#include #include "de_web_plugin.h" #include "de_web_plugin_private.h" #include "tuya.h" +#include "product_match.h" //*********************************************************************************** @@ -76,22 +76,6 @@ //****************************************************************************************** -/*! Returns true if the \p manufacturer name referes to a Tuya device. */ -bool isTuyaManufacturerName(const QString &manufacturer) -{ - return manufacturer.startsWith(QLatin1String("_T")) && // quick check for performance - std::regex_match(qPrintable(manufacturer), std::regex("_T[A-Z][A-Z0-9]{4}_[a-z0-9]{8}")); -} - -// Tests for Tuya manufacturer name -/* - Q_ASSERT(isTuyaManufacturerName("_TZ3000_bi6lpsew")); - Q_ASSERT(isTuyaManufacturerName("_TYZB02_key8kk7r")); - Q_ASSERT(isTuyaManufacturerName("_TYST11_ckud7u2l")); - Q_ASSERT(isTuyaManufacturerName("_TYZB02_keyjqthh")); - Q_ASSERT(!isTuyaManufacturerName("lumi.sensor_switch.aq2")); -*/ - /*! Helper to generate a new task with new task and req id based on a reference */ static void copyTaskReq(TaskItem &a, TaskItem &b) { diff --git a/tuya.h b/tuya.h index 95773ec8f6..3826e39676 100644 --- a/tuya.h +++ b/tuya.h @@ -75,7 +75,6 @@ #define TUYA_QUERY 0x02 #define TUYA_TIME_SYNCHRONISATION 0x24 -bool isTuyaManufacturerName(const QString &manufacturer); bool UseTuyaCluster(const QString &manufacturer); #endif // TUYA_H diff --git a/window_covering.cpp b/window_covering.cpp index c4b246cb00..3670a31010 100644 --- a/window_covering.cpp +++ b/window_covering.cpp @@ -73,6 +73,7 @@ #include "de_web_plugin.h" #include "de_web_plugin_private.h" +#include "product_match.h" int calibrationStep = 0; int operationalStatus = 0; From 18f0bfaf0988b3d0dc0855c923256188d759a95d Mon Sep 17 00:00:00 2001 From: Manuel Pietschmann Date: Tue, 6 Apr 2021 17:44:49 +0200 Subject: [PATCH 2/4] resource.cpp: remove some dependencies --- resource.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resource.cpp b/resource.cpp index d1d33eef8b..9083fb2852 100644 --- a/resource.cpp +++ b/resource.cpp @@ -10,9 +10,8 @@ #include -#include "deconz.h" +#include "deconz/dbg_trace.h" #include "resource.h" -#include "tuya.h" const char *RSensors = "/sensors"; const char *RLights = "/lights"; From d19005fa2af4767bf8db107552f777dae5699792 Mon Sep 17 00:00:00 2001 From: Manuel Pietschmann Date: Tue, 6 Apr 2021 18:01:22 +0200 Subject: [PATCH 3/4] Add product map entries from PRs to not forget them @Smanar I've included these from some open PRs to simplify merging. https://github.com/dresden-elektronik/deconz-rest-plugin/pull/4621 https://github.com/dresden-elektronik/deconz-rest-plugin/pull/4674 https://github.com/dresden-elektronik/deconz-rest-plugin/pull/4577 --- product_match.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/product_match.cpp b/product_match.cpp index 1261c6dbf0..7645ce250d 100644 --- a/product_match.cpp +++ b/product_match.cpp @@ -53,6 +53,7 @@ static const ProductMap products[] = {"_TYST11_ckud7u2l", "kud7u2l", "Tuya", "Tuya_THD HY369 TRV"}, {"_TZE200_ckud7u2l", "TS0601", "Tuya", "Tuya_THD HY369 TRV"}, {"_TZE200_ywdxldoj", "TS0601", "MOES/tuya", "Tuya_THD HY368 TRV"}, + {"_TZE200_fhn3negr", "TS0601", "MOES/tuya", "Tuya_THD MOES TRV"}, {"_TZE200_aoclfnxz", "TS0601", "Moes", "Tuya_THD BTH-002 Thermostat"}, {"_TYST11_jeaxp72v", "eaxp72v", "Essentials", "Tuya_THD Essentials TRV"}, {"_TYST11_kfvq6avy", "fvq6avy", "Revolt", "Tuya_THD NX-4911-675 TRV"}, @@ -60,6 +61,7 @@ static const ProductMap products[] = {"_TYST11_zivfvd7h", "ivfvd7h", "Siterwell", "Tuya_THD GS361A-H04 TRV"}, {"_TZE200_zivfvd7h", "TS0601", "Siterwell", "Tuya_THD GS361A-H04 TRV"}, {"_TYST11_yw7cahqs", "w7cahqs", "Hama", "Tuya_THD Smart radiator TRV"}, + {"_TZE200_cwnjrr72", "TS0601", "MOES", "Tuya_THD HY368 TRV"}, // Tuya Covering {"_TYST11_wmcdj3aq", "mcdj3aq", "Zemismart", "Tuya_COVD ZM25TQ"}, @@ -67,6 +69,7 @@ static const ProductMap products[] = {"_TZE200_fzo2pocs", "TS0601", "Zemismart", "Tuya_COVD ZM25TQ"}, {"_TYST11_xu1rkty3", "u1rkty3", "Smart Home", "Tuya_COVD DT82LEMA-1.2N"}, {"_TZE200_xuzcvlku", "TS0601", "Zemismart", "Tuya_COVD M515EGB"}, + {"_TZE200_rddyvrci", "TS0601", "Moes", "Tuya_COVD AM43-0.45/40-ES-EZ(TY)"}, {"_TZE200_zah67ekd", "TS0601", "MoesHouse / Livolo", "Tuya_COVD AM43-0.45-40"}, {"_TZE200_nogaemzt", "TS0601", "Tuya", "Tuya_COVD YS-MT750"}, {"_TZE200_zpzndjez", "TS0601", "Tuya", "Tuya_COVD DS82"}, @@ -87,6 +90,10 @@ static const ProductMap products[] = {"_TZE200_d0yu2xgi", "TS0601", "NEO/Tuya", "NAS-AB02B0 Siren"}, {"_TZ3000_m0vaazab", "TS0207", "Tuya", "Tuya_RPT Repeater"}, + // Switch + {"_TZE200_dfxkcots", "TS0601", "Earda", "Tuya_DIMSWITCH Earda Dimmer"}, + {"_TZE200_9i9dt8is", "TS0601", "Earda", "Tuya_DIMSWITCH EDM-1ZAA-EU"}, + {nullptr, nullptr, nullptr, nullptr} }; From ba6a0e7701ccaf2a31642fb4d5a9fd58ded6548f Mon Sep 17 00:00:00 2001 From: Manuel Pietschmann Date: Tue, 6 Apr 2021 22:36:29 +0200 Subject: [PATCH 4/4] Move lidlDevice code into product_match.cpp No code change, just relocation. --- de_web_plugin.cpp | 55 ----------------------------------------------- product_match.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++ product_match.h | 9 ++++++++ 3 files changed, 59 insertions(+), 55 deletions(-) diff --git a/de_web_plugin.cpp b/de_web_plugin.cpp index 216299ecb8..1f2c318588 100644 --- a/de_web_plugin.cpp +++ b/de_web_plugin.cpp @@ -490,61 +490,6 @@ static const SupportedDevice supportedDevices[] = { { 0, nullptr, 0 } }; -struct lidlDevice { - const char *zigbeeManufacturerName; - const char *zigbeeModelIdentifier; - const char *manufacturername; - const char *modelid; -}; - -static const lidlDevice lidlDevices[] = { // Sorted by zigbeeManufacturerName - { "_TYZB01_bngwdjsr", "TS1001", "LIDL Livarno Lux", "HG06323" }, // Remote Control - { "_TZ3000_1obwwnmq", "TS011F", "LIDL Silvercrest", "HG06338" }, // Smart USB Extension Lead (EU) - { "_TZ3000_49qchf10", "TS0502A", "LIDL Livarno Lux", "HG06492C" }, // CT Light (E27) - { "_TZ3000_9cpuaca6", "TS0505A", "LIDL Livarno Lux", "14148906L" }, // Stimmungsleuchte - { "_TZ3000_dbou1ap4", "TS0505A", "LIDL Livarno Lux", "HG06106C" }, // RGB Light (E27) - { "_TZ3000_el5kt5im", "TS0502A", "LIDL Livarno Lux", "HG06492A" }, // CT Light (GU10) - { "_TZ3000_gek6snaj", "TS0505A", "LIDL Livarno Lux", "14149506L" }, // Lichtleiste - { "_TZ3000_kdi2o9m6", "TS011F", "LIDL Silvercrest", "HG06337" }, // Smart plug (EU) - { "_TZ3000_kdpxju99", "TS0505A", "LIDL Livarno Lux", "HG06106A" }, // RGB Light (GU10) - { "_TZ3000_oborybow", "TS0502A", "LIDL Livarno Lux", "HG06492B" }, // CT Light (E14) - { "_TZ3000_odygigth", "TS0505A", "LIDL Livarno Lux", "HG06106B" }, // RGB Light (E14) - { "_TZ3000_riwp3k79", "TS0505A", "LIDL Livarno Lux", "HG06104A" }, // LED Light Strip - { "_TZE200_s8gkrkxk", "TS0601", "LIDL Livarno Lux", "HG06467" }, // Smart LED String Lights (EU) - { nullptr, nullptr, nullptr, nullptr } -}; - -static const lidlDevice *getLidlDevice(const QString &zigbeeManufacturerName) -{ - const lidlDevice *device = lidlDevices; - - while (device->zigbeeManufacturerName != nullptr) - { - if (zigbeeManufacturerName == QLatin1String(device->zigbeeManufacturerName)) - { - return device; - } - device++; - } - return nullptr; -} - -static bool isLidlDevice(const QString &zigbeeModelIdentifier, const QString &manufacturername) -{ - const lidlDevice *device = lidlDevices; - - while (device->zigbeeManufacturerName != nullptr) - { - if (zigbeeModelIdentifier == QLatin1String(device->zigbeeModelIdentifier) && - manufacturername == QLatin1String(device->manufacturername)) - { - return true; - } - device++; - } - return false; -} - int TaskItem::_taskCounter = 1; // static rolling taskcounter /*! Returns the largest supported API version. diff --git a/product_match.cpp b/product_match.cpp index 7645ce250d..5291a21765 100644 --- a/product_match.cpp +++ b/product_match.cpp @@ -189,3 +189,53 @@ bool isTuyaManufacturerName(const QString &manufacturer) Q_ASSERT(isTuyaManufacturerName("_TYZB02_keyjqthh")); Q_ASSERT(!isTuyaManufacturerName("lumi.sensor_switch.aq2")); */ + + + +static const lidlDevice lidlDevices[] = { // Sorted by zigbeeManufacturerName + { "_TYZB01_bngwdjsr", "TS1001", "LIDL Livarno Lux", "HG06323" }, // Remote Control + { "_TZ3000_1obwwnmq", "TS011F", "LIDL Silvercrest", "HG06338" }, // Smart USB Extension Lead (EU) + { "_TZ3000_49qchf10", "TS0502A", "LIDL Livarno Lux", "HG06492C" }, // CT Light (E27) + { "_TZ3000_9cpuaca6", "TS0505A", "LIDL Livarno Lux", "14148906L" }, // Stimmungsleuchte + { "_TZ3000_dbou1ap4", "TS0505A", "LIDL Livarno Lux", "HG06106C" }, // RGB Light (E27) + { "_TZ3000_el5kt5im", "TS0502A", "LIDL Livarno Lux", "HG06492A" }, // CT Light (GU10) + { "_TZ3000_gek6snaj", "TS0505A", "LIDL Livarno Lux", "14149506L" }, // Lichtleiste + { "_TZ3000_kdi2o9m6", "TS011F", "LIDL Silvercrest", "HG06337" }, // Smart plug (EU) + { "_TZ3000_kdpxju99", "TS0505A", "LIDL Livarno Lux", "HG06106A" }, // RGB Light (GU10) + { "_TZ3000_oborybow", "TS0502A", "LIDL Livarno Lux", "HG06492B" }, // CT Light (E14) + { "_TZ3000_odygigth", "TS0505A", "LIDL Livarno Lux", "HG06106B" }, // RGB Light (E14) + { "_TZ3000_riwp3k79", "TS0505A", "LIDL Livarno Lux", "HG06104A" }, // LED Light Strip + { "_TZE200_s8gkrkxk", "TS0601", "LIDL Livarno Lux", "HG06467" }, // Smart LED String Lights (EU) + { nullptr, nullptr, nullptr, nullptr } +}; + +const lidlDevice *getLidlDevice(const QString &zigbeeManufacturerName) +{ + const lidlDevice *device = lidlDevices; + + while (device->zigbeeManufacturerName != nullptr) + { + if (zigbeeManufacturerName == QLatin1String(device->zigbeeManufacturerName)) + { + return device; + } + device++; + } + return nullptr; +} + +bool isLidlDevice(const QString &zigbeeModelIdentifier, const QString &manufacturername) +{ + const lidlDevice *device = lidlDevices; + + while (device->zigbeeManufacturerName != nullptr) + { + if (zigbeeModelIdentifier == QLatin1String(device->zigbeeModelIdentifier) && + manufacturername == QLatin1String(device->manufacturername)) + { + return true; + } + device++; + } + return false; +} diff --git a/product_match.h b/product_match.h index ebe6abde0c..baabc3a304 100644 --- a/product_match.h +++ b/product_match.h @@ -15,7 +15,16 @@ class Resource; +struct lidlDevice { + const char *zigbeeManufacturerName; + const char *zigbeeModelIdentifier; + const char *manufacturername; + const char *modelid; +}; + const QString R_GetProductId(Resource *resource); bool isTuyaManufacturerName(const QString &manufacturer); +bool isLidlDevice(const QString &zigbeeModelIdentifier, const QString &manufacturername); +const lidlDevice *getLidlDevice(const QString &zigbeeManufacturerName); #endif // PRODUCT_MATCH_H