Refactor device announce handling
don't reactivate deleted lights unless light search is active
don't emit events for deleted lights
put on top of poll queue to speed up getting the state
@@ -10558,6 +10558,7 @@ void DeRestPluginPrivate::handleDeviceAnnceIndication(const deCONZ::ApsDataIndic
{
val.timestamp = QDateTime();
val.timestampLastReport = QDateTime();
+ val.timestampLastConfigured = QDateTime();
}
std::vector<RecoverOnOff>::iterator rc = recoverOnOff.begin();
@@ -10611,30 +10612,43 @@ void DeRestPluginPrivate::handleDeviceAnnceIndication(const deCONZ::ApsDataIndic
if (item)
{
- item->setValue(true); // refresh timestamp after device announce
- Event e(i->prefix(), RStateReachable, i->id(), item);
- enqueueEvent(e);
-
- // TODO only when permit join is active
+ if (gwPermitJoinDuration > 0)
+ {
if (i->state() == LightNode::StateDeleted)
{
i->setState(LightNode::StateNormal);
i->setNeedSaveDatabase(true);
queSaveDb(DB_LIGHTS,DB_SHORT_SAVE_DELAY);
}
+ }
+
+ item->setValue(true); // refresh timestamp after device announce
+ if (i->state() == LightNode::StateNormal)
+ {
+ Event e(i->prefix(), RStateReachable, i->id(), item);
+ enqueueEvent(e);
+ }
+
updateEtag(gwConfigEtag);
}
DBG_Printf(DBG_INFO, "DeviceAnnce of LightNode: %s Permit Join: %i\n", qPrintable(i->address().toStringExt()), gwPermitJoinDuration);
+ if (i->state() == LightNode::StateNormal)
+ {
// force reading attributes
-
- i->enableRead(READ_SWBUILD_ID |
- READ_GROUPS |
- READ_SCENES);
+ i->enableRead(READ_GROUPS | READ_SCENES);
queuePollNode(&*i);
+ // reorder, bring to back to force next polling
+ auto n = std::find(pollNodes.begin(), pollNodes.end(), &*i);
+ if (n != pollNodes.end())
+ {
+ *n = pollNodes.back();
+ pollNodes.back() = &*i;
+ }
+
for (uint32_t ii = 0; ii < 32; ii++)
{
uint32_t item = 1 << ii;
@@ -10649,6 +10663,7 @@ void DeRestPluginPrivate::handleDeviceAnnceIndication(const deCONZ::ApsDataIndic
updateEtag(i->etag);
}
}
+ }
int found = 0;
std::vector<Sensor>::iterator si = sensors.begin();
