Nanoleaf: auto rediscovery

master
bernhard.trinnes 2020-07-01 12:46:21 +02:00
parent 314fa560b8
commit c1055991df
1 changed files with 9 additions and 0 deletions

View File

@ -359,6 +359,15 @@ void IntegrationPluginNanoleaf::onConnectionChanged(bool connected)
if (!thing)
return;
thing->setStateValue(lightPanelsConnectedStateTypeId, connected);
if (!connected) {
QTimer::singleShot(3000, this, [nanoleaf, thing, connected, this] {
if (!connected) { //If after 3 seconds it is still not connected
nanoleaf->setIpAddress(getHostAddress(thing->paramValue(lightPanelsThingSerialNoParamTypeId).toString()));
nanoleaf->setPort(getPort(thing->paramValue(lightPanelsThingSerialNoParamTypeId).toString()));
nanoleaf->getControllerInfo(); //Test connection
}
});
}
}
void IntegrationPluginNanoleaf::onControllerInfoReceived(const Nanoleaf::ControllerInfo &controllerInfo)