fixed bridge rediscovery
This commit is contained in:
parent
3c3f1b26cf
commit
34cff0ceb5
@ -249,13 +249,19 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
|
|||||||
info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Not authenticated to bridge. Please reconfigure the bridge."));
|
info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Not authenticated to bridge. Please reconfigure the bridge."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
HueBridge *bridge;
|
||||||
HueBridge *bridge = new HueBridge(this);
|
if (m_bridges.values().contains(thing)) {
|
||||||
bridge->setId(thing->paramValue(bridgeThingIdParamTypeId).toString());
|
qCDebug(dcPhilipsHue()) << "Re-Discovery, not creating new bridge" << thing->name();
|
||||||
bridge->setApiKey(apiKey);
|
bridge = m_bridges.key(thing);
|
||||||
bridge->setHostAddress(QHostAddress(thing->paramValue(bridgeThingHostParamTypeId).toString()));
|
bridge->setApiKey(apiKey);
|
||||||
m_bridges.insert(bridge, thing);
|
bridge->setHostAddress(QHostAddress(thing->paramValue(bridgeThingHostParamTypeId).toString()));
|
||||||
|
} else {
|
||||||
|
bridge = new HueBridge(this);
|
||||||
|
bridge->setId(thing->paramValue(bridgeThingIdParamTypeId).toString());
|
||||||
|
bridge->setApiKey(apiKey);
|
||||||
|
bridge->setHostAddress(QHostAddress(thing->paramValue(bridgeThingHostParamTypeId).toString()));
|
||||||
|
m_bridges.insert(bridge, thing);
|
||||||
|
}
|
||||||
discoverBridgeDevices(bridge);
|
discoverBridgeDevices(bridge);
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
@ -495,6 +501,7 @@ void IntegrationPluginPhilipsHue::thingRemoved(Thing *thing)
|
|||||||
abortRequests(m_bridgeSearchDevicesRequests, thing);
|
abortRequests(m_bridgeSearchDevicesRequests, thing);
|
||||||
|
|
||||||
if (thing->thingClassId() == bridgeThingClassId) {
|
if (thing->thingClassId() == bridgeThingClassId) {
|
||||||
|
qCDebug(dcPhilipsHue()) << "Bridge removed" << thing->name();
|
||||||
HueBridge *bridge = m_bridges.key(thing);
|
HueBridge *bridge = m_bridges.key(thing);
|
||||||
m_bridges.remove(bridge);
|
m_bridges.remove(bridge);
|
||||||
bridge->deleteLater();
|
bridge->deleteLater();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user