Documentation
IPS_GetCompatibleParents
string IPS_GetCompatibleParents (int $InstanceID)
Parameters
| InstanceID | ID of the instance |
Returns
JSON encoded object which describes the compatible parent instances. The structure (type, moduleIDs or modules) is described at GetCompatibleParents. If the instance does not need a parent instance, "{}" is returned.
Description
The function returns a JSON encoded object which describes the parent instances the instance with the ID InstanceID can be connected to. The management console uses this information to suggest suitable parent instances when creating or editing the instance. With "require", a new instance or an instance without other child instances is needed, with "connect", existing compatible instances are suggested as well.
For PHP modules, the result of the module's function GetCompatibleParents is returned. If it is not implemented, a specification made with ConnectParent, RequireParent or ForceParent (like RequireParent) is used. If there is none either, the specification is determined based on the module type:
| Module type | Result |
|---|---|
| Core, I/O, Visualization | "{}" |
| Device, Configurator | type "connect" with all modules compatible according to the data flow (IPS_GetCompatibleModules) |
| Splitter, Discovery | type "require" with all modules compatible according to the data flow (IPS_GetCompatibleModules) |
If there are no compatible modules, "{}" is returned as well. If the instance does not exist, the function fails with "Instance #... does not exist". The IDs of already existing compatible instances are returned by IPS_GetCompatibleInstances.
Example
// Determine the compatible parent instances of instance 12345 (e.g. a ThermoJet)
$parents = json_decode(IPS_GetCompatibleParents(12345), true);
print_r($parents);
/* e.g. returns:
Array
(
[moduleIDs] => Array
(
[0] => {6DC3D946-0D31-450F-A8C6-C42DB8D7D4F1}
)
[type] => require
)
*/