Shelly: Fix creation of children for the Plus 2PM

This commit is contained in:
Michael Zanetti 2023-03-17 22:07:45 +01:00
parent 4acddd2219
commit f4eba66fbb

View File

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