From c1055991df5f72277612b06bbbc5addff34d1865 Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Wed, 1 Jul 2020 12:46:21 +0200 Subject: [PATCH] Nanoleaf: auto rediscovery --- nanoleaf/integrationpluginnanoleaf.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nanoleaf/integrationpluginnanoleaf.cpp b/nanoleaf/integrationpluginnanoleaf.cpp index e00659c2..159e626f 100644 --- a/nanoleaf/integrationpluginnanoleaf.cpp +++ b/nanoleaf/integrationpluginnanoleaf.cpp @@ -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)