Skip to content

Commit

Permalink
Improve Xiaomi device joining
Browse files Browse the repository at this point in the history
Provide data from first special report right after sensor creation.
Therefore battery level and the like will be available from the beginning.

The Datecode version will be queried after an hour and reception of the
special report.
  • Loading branch information
manup committed Dec 16, 2018
1 parent 101b509 commit 6c05cc7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
30 changes: 24 additions & 6 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4325,11 +4325,23 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const SensorFi
{
fastProbeTimer->start(100);
}

if (modelId.startsWith(QLatin1String("lumi.")))
{
for (const auto &ind : fastProbeIndications)
{
if (ind.clusterId() == BASIC_CLUSTER_ID && ind.profileId() != ZDP_PROFILE_ID)
{
apsdeDataIndication(ind); // replay Xiaomi special report
}
}
}
}

sensor2->rx();
checkSensorBindingsForAttributeReporting(sensor2);


Q_Q(DeRestPlugin);
q->startZclAttributeTimer(checkZclAttributesDelay);

Expand Down Expand Up @@ -8500,6 +8512,11 @@ void DeRestPluginPrivate::handleZclAttributeReportIndicationXiaomiSpecial(const
}
}

if (searchSensorsState == SearchSensorsActive)
{
return;
}

if (!restNodePending)
{
return;
Expand All @@ -8512,6 +8529,13 @@ void DeRestPluginPrivate::handleZclAttributeReportIndicationXiaomiSpecial(const
return;
}

if (dateCode.isEmpty() && restNodePending)
{
// read datecode, will be applied to all sensors of this device
readAttributes(restNodePending, ind.srcEndpoint(), BASIC_CLUSTER_ID, { 0x0006 });
return;
}

ResourceItem *item = r->item(RAttrModelId);
if (item && item->toString() == QLatin1String("lumi.vibration.aq1"))
{
Expand Down Expand Up @@ -8540,12 +8564,6 @@ void DeRestPluginPrivate::handleZclAttributeReportIndicationXiaomiSpecial(const
}
}
}

if (dateCode.isEmpty() && restNodePending)
{
// read datecode, will be applied to all sensors of this device
readAttributes(restNodePending, ind.srcEndpoint(), BASIC_CLUSTER_ID, { 0x0006 });
}
}

void DeRestPluginPrivate::queuePollNode(RestNodeBase *node)
Expand Down
5 changes: 5 additions & 0 deletions rest_sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,11 @@ void DeRestPluginPrivate::handleIndicationSearchSensors(const deCONZ::ApsDataInd

if (sc && fastProbeAddr.hasExt() && sc->address.ext() == fastProbeAddr.ext())
{
if (zclFrame.manufacturerCode() == VENDOR_115F)
{
fastProbeIndications.push_back(ind); // remember Xiaomi special report
}

if (!fastProbeTimer->isActive())
{
fastProbeTimer->start(5);
Expand Down

0 comments on commit 6c05cc7

Please sign in to comment.