Shelly: Provide defaults for all params
This commit is contained in:
parent
ac6dcf0765
commit
4c1b0b56c9
@ -208,19 +208,28 @@ void IntegrationPluginShelly::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCDebug(dcShelly()) << "Found shelly thing!" << entry;
|
||||||
|
|
||||||
ThingDescriptor descriptor(info->thingClassId(), entry.name(), entry.hostAddress().toString());
|
ThingDescriptor descriptor(info->thingClassId(), entry.name(), entry.hostAddress().toString());
|
||||||
ParamList params;
|
ParamList params;
|
||||||
params << Param(m_idParamTypeMap.value(info->thingClassId()), entry.name());
|
params << Param(m_idParamTypeMap.value(info->thingClassId()), entry.name());
|
||||||
|
params << Param(m_usernameParamTypeMap.value(info->thingClassId()), "");
|
||||||
|
params << Param(m_passwordParamTypeMap.value(info->thingClassId()), "");
|
||||||
|
if (m_connectedDeviceParamTypeMap.contains(info->thingClassId())) {
|
||||||
|
params << Param(m_connectedDeviceParamTypeMap.value(info->thingClassId()), "None");
|
||||||
|
}
|
||||||
|
if (m_connectedDevice2ParamTypeMap.contains(info->thingClassId())) {
|
||||||
|
params << Param(m_connectedDevice2ParamTypeMap.value(info->thingClassId()), "None");
|
||||||
|
}
|
||||||
descriptor.setParams(params);
|
descriptor.setParams(params);
|
||||||
|
|
||||||
Thing *existingThing = myThings().findByParams(params);
|
Things existingThings = myThings().filterByParam(m_idParamTypeMap.value(info->thingClassId()), entry.name());
|
||||||
if (existingThing) {
|
if (existingThings.count() == 1) {
|
||||||
descriptor.setThingId(existingThing->id());
|
qCDebug(dcShelly()) << "This shelly already exists in the system!";
|
||||||
|
descriptor.setThingId(existingThings.first()->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
info->addThingDescriptor(descriptor);
|
info->addThingDescriptor(descriptor);
|
||||||
qCDebug(dcShelly()) << "Found shelly thing!" << entry;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user