Fix 'reachable' for nodes loaded from cache
@@ -1152,16 +1152,19 @@ void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node)
lightNode2->setManufacturerCode(node->nodeDescriptor().manufacturerCode());
ResourceItem *reachable = lightNode2->item(RStateReachable);
- DBG_Assert(reachable != 0);
- if (!reachable->toBool())
+ DBG_Assert(reachable);
+ bool avail = !node->isZombie();
+ if (reachable->toBool() != avail)
{
// the node existed before
// refresh all with new values
DBG_Printf(DBG_INFO, "LightNode %u: %s updated\n", lightNode2->id().toUInt(), qPrintable(lightNode2->name()));
- reachable->setValue(true);
+ reachable->setValue(avail);
Event e(RLights, RStateReachable, lightNode2->id(), reachable);
enqueueEvent(e);
+ if (avail)
+ {
lightNode2->enableRead(READ_VENDOR_NAME |
READ_MODEL_ID |
READ_SWBUILD_ID |
@@ -1188,6 +1191,7 @@ void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node)
//lightNode2->setLastRead(idleTotalCounter);
updateEtag(lightNode2->etag);
}
+ }
if (lightNode2->uniqueId().isEmpty() || lightNode2->uniqueId().startsWith(QLatin1String("0x")))
{
@@ -1361,6 +1365,13 @@ void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node)
}
}
+ ResourceItem *reachable = lightNode.item(RStateReachable);
+ DBG_Assert(reachable);
+ if (reachable)
+ {
+ reachable->setValue(!node->isZombie());
+ }
+
if (lightNode.id().isEmpty())
{
openDb();
