Shelly: Fix creation of children for the Plus 2PM

master
Michael Zanetti 2023-03-17 22:07:45 +01:00
parent 4acddd2219
commit f4eba66fbb
1 changed files with 18 additions and 15 deletions

View File

@ -1701,27 +1701,30 @@ void IntegrationPluginShelly::setupGen2(ThingSetupInfo *info)
});
if (myThings().filterByParentId(info->thing()->id()).count() == 0) {
ThingDescriptors children;
ThingDescriptor switchChild(shellySwitchThingClassId, info->thing()->name() + " switch 1", QString(), info->thing()->id());
switchChild.setParams(ParamList() << Param(shellySwitchThingChannelParamTypeId, 1));
emit autoThingsAppeared({switchChild});
children.append(switchChild);
ThingDescriptor switch2Child(shellySwitchThingClassId, info->thing()->name() + " switch 2", QString(), info->thing()->id());
switch2Child.setParams(ParamList() << Param(shellySwitchThingChannelParamTypeId, 2));
emit autoThingsAppeared({switch2Child});
}
children.append(switch2Child);
if (rollerMode == true) {
ThingDescriptor rollerShutterChild(shellyRollerThingClassId, info->thing()->name() + " connected shutter", QString(), info->thing()->id());
rollerShutterChild.setParams(ParamList() << Param(shellyRollerThingChannelParamTypeId, 1));
emit autoThingsAppeared({rollerShutterChild});
children.append(rollerShutterChild);
// Create 2 measurement channels for Shelly Plus 2PM (unless in roller mode)
} else {
ThingDescriptor channelChild(shellyPowerMeterChannelThingClassId, info->thing()->name() + " channel 1", QString(), info->thing()->id());
channelChild.setParams(ParamList() << Param(shellyPowerMeterChannelThingChannelParamTypeId, 1));
emit autoThingsAppeared({channelChild});
children.append(channelChild);
ThingDescriptor channel2Child(shellyPowerMeterChannelThingClassId, info->thing()->name() + " channel 2", QString(), info->thing()->id());
channel2Child.setParams(ParamList() << Param(shellyPowerMeterChannelThingChannelParamTypeId, 2));
emit autoThingsAppeared({channel2Child});
children.append(channel2Child);
}
emit autoThingsAppeared(children);
}
return;
}