Endpoint configuration
The endpoint configuration object represents the initial configuration of an endpoint, typically in device model configuration scripts.
Objects of this type are created through the add() method of the endpoint configuration collection object.
Properties
### address (string) The address property represents the address of the endpoint, as text.
Examples
This example shows the address of an endpoint, through the log console.
env.log('Endoint address: ', endpoint.address);### defaultDescription (string or multi-language literal) The defaultDescription property represents the description that will be used when creating the endpoint. It can be a string, or a multi-language literal object.
Examples
This example shows the description of an endpoint, through the log console.
env.log('Endoint description: ', endpoint.defaultDescription);### endpointType (int enum) The endpointType property indicates the endpoint type. The possible values for this property are the same as those of the endpointType property of the endpoint object.
Examples
This example shows the type of an endpoint, through the log console.
env.log('Endoint type: ', endpoint.endpointType);### endpointSubType (int enum) The endpointSubType property indicates the endpoint subtype. The possible values for this property are the same as those of the endpointSubType property of the endpoint object.
Examples
This example shows the subtype of an endpoint, through the log console.
env.log('Endoint subtype: ', endpoint.endpointSubType);### variableTypeId (int enum) The variableTypeId property indicates the custom variable type associated with the endpoint. This property applies only to endpoints of type endpointType.genericSensor and endpointType.genericFlowSensor.
Examples
This example creates a flow sensor type endpoint and assigns it the variable with ID 1071.
var e = endpoints.addEndpoint("1", "My generic sensor", endpointType.genericSensor);
e.variableTypeId = 1071;### accessType (int enum) The accessType property indicates the type of access applied to the endpoint. By default, access will be read only. The possible values for this property are the same as those of the accessType property of the endpoint object.
Examples
This example creates a generic sensor type endpoint and assigns it read-write access.
var e = endpoints.addEndpoint("1", "My generic sensor", endpointType.genericSensor);
e.accessType = endpointAccessType.readWrite;### operationSecurityLevel (int enum) The operationSecurityLevel property indicates the security level associated with the endpoint operation. By default, the security level will be simple. The possible values for this property are the same as those of the operationSecurityLevel property of the endpoint object.
Examples
This example creates a generic sensor type endpoint and assigns it a medium security level.
var e = endpoints.addEndpoint("1", "My generic sensor", endpointType.genericSensor);
e.operationSecurityLevel = endpointOperationSecurityLevel.medium;### operationWarningMessage (string or multi-language literal) The operationWarningMessage property represents the warning message that will be displayed when attempting to manually operate the device, if the security level in the operationSecurityLevel property is medium or high. It can be a string, or a multi-language literal object.
Examples
This example creates a generic sensor type endpoint and assigns it a multi-language warning message.
var e = endpoints.addEndpoint("1", "My generic sensor", endpointType.genericSensor);
e.operationWarningMessage = {en: "This is a critical operation. Continue?", es: "Esta es una operación crítica. ¿Continuar?"};### range (endpoint range) The range property allows indicating the range of allowed values for an endpoint. It is only applicable to scalar type endpoints. The range is expressed as an endpoint range type object. The default value for this property is null, indicating that any value is acceptable.
Examples
This example creates a generic sensor type endpoint and assigns it a value range from -100 to +100.
var e = endpoints.addEndpoint("1", "My generic sensor", endpointType.genericSensor);
e.range = {lowestValue: -100, highestValue: 100};### summationAutoResetThreshold (int or null)
The summationAutoResetThreshold property controls the endpoint behavior when a cumulative value lower than the last received one is received. This property applies only to endpoints of type endpointType.flowSensor, endpointType.genericFlowSensor, endpointType.peopleFlowSensor, and endpointType.energyMeter.
When a cumulative value lower than the previous one is received, the platform must decide how to interpret the new value. Typically, some devices may send a lower value if there has actually been "negative" consumption, for example:
- When a flow sensor is capable of measuring flow in the opposite direction to normal.
- When an energy meter is capable of measuring generated energy, rather than only measuring consumed energy.
However, many other devices report a value lower than the last when they are restarted or powered off, because they only maintain the cumulative value in volatile memory. When restarted or powered off, they lose the accumulated count, resetting it to zero.
The summationAutoResetThreshold property can take any of the following values:
- null: indicates that a threshold for the cumulative value is not used. If a value lower than the last is received, it will be considered as "negative" consumption.
- 0 (zero): indicates that when a value lower than the last is received, it should be considered that the device has reset the cumulative value, because it has lost the previous value. The new value is then considered as a positive consumption value.
- Any value greater than zero: when receiving a cumulative value lower than the last received, the platform will consider that the cumulative has been reset only if the difference between the previous value and the new value is greater than or equal to the specified threshold. If the difference is less than this threshold, it will be considered as negative consumption.
It is recommended that for all devices that are not capable of measuring negative flows, the value of this property be set to zero.
Examples
This example creates a generic sensor type endpoint and assigns the value zero to the summationAutoResetThreshold property.
var e = endpoints.addEndpoint("1", "My flow sensor", endpointType.flowSensor);
e.summationAutoResetThreshold = 0;### tags (array) The tags property indicates the set of tags applied to the endpoint. This property is an array of strings, each of which indicates a tag.
Examples
This example creates a generic sensor type endpoint and assigns three tags corresponding to the texts "sensor", "generic", and "customer1".
var e = endpoints.addEndpoint("1", "My generic sensor", endpointType.genericSensor);
e.tags = ["sensor", "generic", "customer1"];### requiresElectricalCircuit (boolean)
The requiresElectricalCircuit property indicates whether the endpoint should automatically create an associated electrical circuit when the device is registered in the platform.
This property only applies to endpoints of type **endpointType.voltageSensor**.
For all other endpoint types, the property is ignored and its behavior remains unchanged.
The default value of this property is false, meaning no electrical circuit will be created unless explicitly indicated.
Examples
This example creates a voltage sensor type endpoint and configures the property so that an electrical circuit is automatically created in the platform:
var voltageSensor = endpoints.addEndpoint("2", "Battery", endpointType.voltageSensor);
voltageSensor.requiresElectricalCircuit = true;Methods
### addAlert() The addAlert() method allows creating a new alert related to the endpoint. The method returns an alert object that must be configured with the corresponding parameters.
Result
The result of this method is an alert object, which must be configured through the following properties:
- variableTypeId (int): indicates the variable type associated with the alert. It must correspond to a variable type supported by the endpoint. The identifier of any custom variable, or any of the predefined variable types, can be used, as long as they are supported by the endpoint. The values corresponding to predefined variable types are as follows:
- variableType.temperature (1)
- variableType.humidity (2)
- variableType.lightLevel (3)
- variableType.setPoint (4)
- variableType.volume (5)
- variableType.activeEnergy (6)
- variableType.runTime (7)
- variableType.discreteSensorState (8)
- variableType.dimmerization (9)
- variableType.weight (10)
- variableType.flow (11)
- variableType.voltage (12)
- variableType.current (13)
- variableType.activePower (14)
- variableType.reactivePower (15)
- variableType.apparentPower (16)
- variableType.cosPhi (17)
- variableType.pressure (18)
- variableType.frequency (19)
- variableType.ppmConcentration (20)
- variableType.mvConcentration (21)
- variableType.aqi (22)
- variableType.peopleFlow (23)
- variableType.peopleCount (24)
- variableType.reactiveEnergy (25)
- variableType.apparentEnergy (26)
- variableType.location (27)
- conditionType (enum): indicates the condition type used to trigger the alert. It can be one of the following values:
- conditionType.equal (1): indicates that the value must equal the specified value.
- conditionType.notEqual (2): indicates that the value must differ from the specified value.
- conditionType.greater (3): indicates that the value must be greater than the specified value.
- conditionType.greaterOrEqual (4): indicates that the value must be greater than or equal to the specified value.
- conditionType.lower (5): indicates that the value must be less than the specified value.
- conditionType.lowerOrEqual (6): indicates that the value must be less than or equal to the specified value.
- threshold (double): indicates the value used to trigger the alert, according to the condition type.
- normalConditionType (enum): indicates the condition type used to close the alert. The values are the same as those of the conditionType field.
- normalThreshold (double): indicates the value used to close the alert, according to the normal condition type.
- minimumDurationSeconds (int): indicates that the trigger condition must be maintained for a certain time, specified in seconds, for the alert to trigger. The default value is zero, indicating that the alert triggers immediately.
- severity (enum): indicates the alert severity. It can be one of the following values:
- alarmSeverity.Information (0): informational alert.
- alarmSeverity.low (1): low severity alert.
- alarmSeverity.medium (2): medium severity alert.
- alarmSeverity.high (3): high severity alert.
- geoZoneId (int): geozone identifier, in case the alert refers to entry or exit of a geozone.
- notificationEmails (string[]): array of strings indicating the email addresses of people who should be notified when the alert triggers or closes. Contacts can be specified using the form "@ab:id" where "id" indicates the contact identifier in the address book.
- notificationSmsNumbers (string[]): array of strings indicating the phone numbers of people who should be notified by SMS when the alert triggers or closes. Contacts can be specified using the form "@ab:id" where "id" indicates the contact identifier in the address book.
- notificationVoiceNumbers (string[]): array of strings indicating the phone numbers of people who should be notified by voice call when the alert triggers or closes. Contacts can be specified using the form "@ab:id" where "id" indicates the contact identifier in the address book.
- emailTemplates (object): optional object indicating the template used for email, both for opening and closing the alert.
Allows the use of variables and has the following properties:
- openSubjectTemplate (string): template to use for the subject when opening the alert. If left blank or set to null, the default subject will be used.
- openTemplate (string): template for opening the alert. If left blank or set to null, the default template will be used.
- closeSubjectTemplate (string): template to use for the subject when closing the alert. If left blank or set to null, the default subject will be used.
- closeTemplate (string): template for closing the alert. If left blank or set to null, the default template will be used.
- smsTemplates (object): optional object indicating the template used for text messages, both for opening and closing the alert. It has the same properties as the emailTemplates object. The openSubjectTemplate and closeSubjectTemplate properties will be ignored.
- voiceTemplates (object): optional object indicating the template used for voice calls, both for opening and closing the alert. It has the same properties as the emailTemplates object. The openSubjectTemplate and closeSubjectTemplate properties will be ignored.
- tags (string[]): array of strings optionally indicating tags for the alert.
Example 1
This example shows the creation of an alert for an endpoint.
var alert = myEndpoint.addAlert();
alert.variableTypeId = variableType.temperature;
alert.conditionType = conditionType.greater;
alert.threshold = 25;
alert.normalConditionType = conditionType.lowerOrEqual;
alert.normalThreshold = 20;
alert.severity = alarmSeverity.medium;
alert.notificationEmails = ['someone@somedomain.com', 'someone_else@somedomain.com'];
alert.tags = ['alert', 'test'];
alert.emailTemplates = [ openTemplate: "correo@email.com", closeTemplate: "correo2@email.com" ];