fixed mDNS discovery bridgeId
This commit is contained in:
parent
1071bcb34b
commit
5760025af3
@ -87,14 +87,13 @@ void IntegrationPluginPhilipsHue::init()
|
|||||||
QString thingId = thing->paramValue(bridgeThingIdParamTypeId).toString();
|
QString thingId = thing->paramValue(bridgeThingIdParamTypeId).toString();
|
||||||
if (entry.protocol() == QAbstractSocket::IPv4Protocol) {
|
if (entry.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
|
|
||||||
QString name = entry.name().split(" - ").first();
|
foreach (const QString &txtEntry, entry.txt()) {
|
||||||
QString id = entry.name().split(" - ").last();
|
QStringList parts = txtEntry.split('=');
|
||||||
|
if (parts.length() == 2 && parts.first() == "bridgeid" && parts.last().toLower() == thingId) {
|
||||||
if (thingId.contains(id)) {
|
thing->setParamValue(bridgeThingHostParamTypeId, entry.hostAddress().toString());
|
||||||
thing->setParamValue(bridgeThingHostParamTypeId, entry.hostAddress().toString());
|
HueBridge *bridge = m_bridges.key(thing);
|
||||||
HueBridge *bridge = m_bridges.key(thing);
|
bridge->setHostAddress(entry.hostAddress());
|
||||||
bridge->setHostAddress(entry.hostAddress());
|
}
|
||||||
//TODO also add upnp to update the address
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,13 +126,20 @@ void IntegrationPluginPhilipsHue::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
* service: hue
|
* service: hue
|
||||||
* name: Philips Hue - xxxxxx where xxxxxx are the last 6 digits of the bridge ID.
|
* name: Philips Hue - xxxxxx where xxxxxx are the last 6 digits of the bridge ID.
|
||||||
*/
|
*/
|
||||||
if (!entry.serviceType().contains("_hue._tcp._local")) {
|
if (!entry.serviceType().contains("_hue._tcp._local") || entry.protocol() != QAbstractSocket::IPv4Protocol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
qCDebug(dcPhilipsHue()) << "Zeroconf entry:" << entry;
|
qCDebug(dcPhilipsHue()) << "Zeroconf entry:" << entry;
|
||||||
|
|
||||||
QString name = entry.name().split(" - ").first();
|
QString id;
|
||||||
QString id = entry.name().split(" - ").last();
|
foreach (const QString &txt, entry.txt()) {
|
||||||
|
QString field = txt.split("=").first();
|
||||||
|
QString value = txt.split("=").last();
|
||||||
|
if (field == "bridgeid") {
|
||||||
|
id = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
QHostAddress address = entry.hostAddress();
|
QHostAddress address = entry.hostAddress();
|
||||||
|
|
||||||
ParamList params;
|
ParamList params;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user