IoTUtilities#
Note
This is advanced documentation regarding a scope that can be accessed when executing a step of type Script.
This document provides an overview of the public methods in the ScriptScopeIoTUtilities class. These methods facilitate the handling of IoT entities, events, properties, and related operations.
Methods#
allEntityTypesFromController#
allEntityTypesFromController(automationController: Cmf.Foundation.BusinessObjects.AutomationController): string[]
Retrieves all entity types used in the controller and associated drivers.
automationController: The automation controller object.
An array of entity type names.
{
"name": "Example AllEntityTypesFromController",
"type": "Script",
"resultKey": "iotEntityTypesWithStateModels",
"settings": {
"script": [
"(async () => {",
" const entityTypes = await this.iotUtilities.allEntityTypesFromController(entityInstance);",
" const entityTypesWithStateModels = await this.lboUtilities.entityTypesWithStateModel(entityTypes, true);",
" if(entityTypesWithStateModels == null || entityTypesWithStateModels.length == 0) {",
" throw new Error('No State Model found for Entity Types associated with this controller');",
" }",
"return entityTypesWithStateModels;",
"})()"
]
},
"next": "SelectEntityType"
}
allDriversFromController#
allDriversFromController(automationController: Cmf.Foundation.BusinessObjects.AutomationController): Map<string, Cmf.Foundation.BusinessObjects.AutomationDriverDefinition>
Retrieves all friendly names and driver definitions from a controller.
automationController: The automation controller object.
A map of driver names to their definitions.
{
"name": "Example AllDriversFromController",
"type": "Script",
"resultKey": "iotControllerDrivers",
"settings": {
"script": [
"const iotDriversMap = this.iotUtilities.allDriversFromController(entityInstance);",
"const iotDriversMapFiltered = new Map([...iotDriversMap].filter(([key, value]) => value.ObjectType.Name === this.answers.iotEntityType.Name));",
"const iotDrivers = Array.from(iotDriversMapFiltered?.keys());",
"this.lboUtilities.convertArrayOfStringsToEnum(iotDrivers);"
]
},
"next": "CheckDrivers"
}
allEventNamesFromDriver#
allEventNamesFromDriver(driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): string[] | undefined
Retrieves all event names from a driver, merging template and driver definition events.
driverName: The name of the driver.automationController: The automation controller object.
An array of event names or undefined if inputs are invalid.
{
"name": "Example AllEventNamesFromDriver",
"type": "Script",
"resultKey": "iotControllerDriverEvents",
"settings": {
"script": [
"const driverEvents = this.iotUtilities.allEventNamesFromDriver(this.answers.iotControllerDriver, entityInstance);",
"this.lboUtilities.convertArrayOfStringsToEnum(driverEvents);"
]
},
"next": "AskWhichDriverEvent"
}
getEventByName#
getEventByName(eventName: string, driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): Cmf.Foundation.BusinessObjects.AutomationEvent | undefined
Retrieves an event by its name.
eventName: The name of the event.driverName: The name of the driver.automationController: The automation controller object.
The event object or undefined.
isTemplateEvent#
isTemplateEvent(eventName: string, driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): boolean | null | undefined
Checks if an event is a template event.
eventName: The name of the event.driverName: The name of the driver.automationController: The automation controller object.
trueif the event is a template event.falseif it is not.nullif no matching event or template event is found.undefinedfor invalid inputs.
allCommandNamesFromDriver#
allCommandNamesFromDriver(driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): string[] | undefined
Retrieves all command names from a driver, merging template and driver definition commands.
driverName: The name of the driver.automationController: The automation controller object.
An array of command names or undefined.
allPropertyNamesFromDriver#
allPropertyNamesFromDriver(driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): string[] | undefined
Retrieves all property names from a driver, merging template and driver definition properties.
driverName: The name of the driver.automationController: The automation controller object.
An array of property names or undefined.
allPropertyNamesFromAnEvent#
allPropertyNamesFromAnEvent(eventName: string, driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): string[] | undefined
Retrieves all property names associated with an event.
eventName: The name of the event.driverName: The name of the driver.automationController: The automation controller object.
An array of property names or undefined.
{
"name": "Example AllPropertyNamesFromAnEvent",
"type": "Script",
"resultKey": "iotControllerDriverEventProperties",
"settings": {
"script": [
"const driverEventProperties = this.iotUtilities.allPropertyNamesFromAnEvent(this.answers.iotControllerDriverEvent,this.answers.iotControllerDriver, entityInstance);",
"this.lboUtilities.convertArrayOfStringsToEnum(driverEventProperties);"
]
},
"next": "IsMultiProp"
}
allPropertiesFromAnEvent#
allPropertiesFromAnEvent(eventName: string, driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): Cmf.Foundation.BusinessObjects.AutomationProperty[] | undefined
Retrieves all properties associated with an event.
eventName: The name of the event.driverName: The name of the driver.automationController: The automation controller object.
An array of property objects or undefined.
getPropertyByName#
getPropertyByName(propertyName: string, driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): Cmf.Foundation.BusinessObjects.AutomationProperty | undefined
Retrieves a property by its name.
propertyName: The name of the property.driverName: The name of the driver.automationController: The automation controller object.
The property object or undefined.
{
"name": "Example GetPropertyByName",
"type": "Script",
"resultKey": "iotCurrentProp",
"settings": {
"script": [
"Object.assign({}, this.iotUtilities.getPropertyByName(this.answers.iotControllerDriverEventProperties[0].Id, this.answers.iotControllerDriver, entityInstance));"
]
},
"next": "IsPropTypeValid"
}
getPropertyDataType#
getPropertyDataType(dataType: string | number): { name: string, type: PropertyValueType }
Converts a property data type into a structured format.
dataType: The data type as a string or number.
An object containing the name and type.
generateOnEquipmentEventSettings#
generateOnEquipmentEventSettings(selectedEventName: string, driverName: string, automationController: Cmf.Foundation.BusinessObjects.AutomationController): any
Generates settings for a task triggered by an equipment event.
selectedEventName: The name of the selected event.driverName: The name of the driver.automationController: The automation controller object.
An object containing the generated settings.