Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX, Better Tuya reconization #4616

Merged
merged 7 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3709,7 +3709,7 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
{
clusterId = POWER_CONFIGURATION_CLUSTER_ID;
}
if (sensor.manufacturer() == QLatin1String("_TYST11_xu1rkty3"))
else if (sensor.fingerPrint().hasInCluster(TUYA_CLUSTER_ID))
{
clusterId = TUYA_CLUSTER_ID;
}
Expand Down
6 changes: 5 additions & 1 deletion de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5562,6 +5562,10 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const deCONZ::
{
fpThermostatSensor.inClusters.push_back(TUYA_CLUSTER_ID);
}
if (manufacturer == QLatin1String("_TZE200_xuzcvlku"))
{
fpBatterySensor.inClusters.push_back(TUYA_CLUSTER_ID);
}
}
break;

Expand Down Expand Up @@ -6769,7 +6773,7 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const SensorFi
{
clusterId = POWER_CONFIGURATION_CLUSTER_ID;
}
if (sensorNode.manufacturer() == QLatin1String("_TYST11_xu1rkty3"))
else if (sensorNode.fingerPrint().hasInCluster(TUYA_CLUSTER_ID))
{
clusterId = TUYA_CLUSTER_ID;
}
Expand Down
14 changes: 8 additions & 6 deletions resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,15 @@ const QString R_GetProductId(Resource *resource)
}

const auto *manufacturerName = resource->item(RAttrManufacturerName);
const auto *modelId = resource->item(RAttrManufacturerName);
const auto *modelId = resource->item(RAttrModelId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch


if (!manufacturerName || !modelId)
// Need manufacturerName
if (!manufacturerName)
{
return rInvalidString;
}


//Tuya don't need modelId
if (isTuyaManufacturerName(manufacturerName->toString()))
{
// for Tuya devices match against manufacturer name
Expand All @@ -576,14 +578,14 @@ const QString R_GetProductId(Resource *resource)
// 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, modelId: %s\n",
qPrintable(manufacturerName->toString()), qPrintable(modelId->toString()));
DBG_Printf(DBG_INFO_L2, "No Tuya productId entry found for manufacturername: %s\n", qPrintable(manufacturerName->toString()));
}

return manufacturerName->toString();
}
}
else

if (modelId)
{
return modelId->toString();
}
Expand Down