Merge PR #389: Shelly: Don't complete setup for childs when the parent setup fails
This commit is contained in:
commit
9485c2bebd
@ -1293,6 +1293,25 @@ void IntegrationPluginShelly::setupShellyGateway(ThingSetupInfo *info)
|
|||||||
void IntegrationPluginShelly::setupShellyChild(ThingSetupInfo *info)
|
void IntegrationPluginShelly::setupShellyChild(ThingSetupInfo *info)
|
||||||
{
|
{
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
|
qCDebug(dcShelly()) << "Setting up shelly child:" << info->thing()->name();
|
||||||
|
|
||||||
|
Thing *parent = myThings().findById(thing->parentId());
|
||||||
|
Q_ASSERT_X(parent != nullptr, "Shelly::setupChild", "Child has no parent!");
|
||||||
|
if (!parent->setupComplete()) {
|
||||||
|
qCDebug(dcShelly()) << "Parent for" << info->thing()->name() << "is not set up yet... Waiting...";
|
||||||
|
// If the parent isn't set up yet, wait for it...
|
||||||
|
connect(parent, &Thing::setupStatusChanged, info, [=](){
|
||||||
|
qCDebug(dcShelly()) << "Setup for" << parent->name() << "Completed. Continuing with setup of child" << info->thing()->name();
|
||||||
|
if (parent->setupStatus() == Thing::ThingSetupStatusComplete) {
|
||||||
|
setupShellyChild(info);
|
||||||
|
} else if (parent->setupStatus() == Thing::ThingSetupStatusFailed) {
|
||||||
|
info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCDebug(dcShelly()) << "Parent for" << info->thing()->name() << "is set up. Finishing child setup.";
|
||||||
|
|
||||||
// Connect to settings changes to store them to the thing
|
// Connect to settings changes to store them to the thing
|
||||||
connect(info->thing(), &Thing::settingChanged, this, [this, thing](const ParamTypeId ¶mTypeId, const QVariant &value){
|
connect(info->thing(), &Thing::settingChanged, this, [this, thing](const ParamTypeId ¶mTypeId, const QVariant &value){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user