Project

General

Profile

Actions

Javascript » History » Revision 10

« Previous | Revision 10/28 (diff) | Next »
Torbjorn Carlqvist Admin, 09/01/2021 03:39 PM


Javascript guide for DTXr code IDE

Shows the various commands and events that can be used to build automation scripts.

#Commands
#Events

Commands

print - Prints a message to footer log window as well as the automation.log file

print("hello");

readProperty - Reads an object property value


/***********************************************************************************************
 * @param {Number} device - The device id
 * @param {Number} objectType - The object type. Both id and enumerated names can be used.
 * @param {Number} objectInstance - The object instance. Must be a positive number.
 * @param {Number} propertyId - The property id. Both id and enumerated names can be used.
 ***********************************************************************************************/

//Reads a present value from analog input object 0.
Controller.readProperty(85343,analogInput,0,presentValue);

//Use the result to print and in logic
res = Controller.readProperty(85343,analogInput,0,presentValue);
print(res);
if ( res > 0 ){
  print("value larger than 0!");
}

Events

eventNotificationReceived - Called when an intrinsic report notification is received.

/***********************************************************************************************
 * @param {Number} device - The device that send the event
 * @param {Number} objectType - The source object of the event
 * @param {Number} objectInstance - The instance of source object
 * @param {Number} eventType - The type of event received
 * @param {String} fromState - The previous state
 * @param {String} toState - The current state after the change
 * @param {Object} eventValues - A map of specific values for this particular eventType 
 ***********************************************************************************************/
function eventNotificationReceived(processIdentifier,initiatingDevice,object,objectType,objectInstance,timeStampUTC,notificationClass,priority,eventType,messageText,notifyType,ackRequired,fromState,toState,eventValues){
//Use this event to act on notifications that is set to be subscribed by this device.
}

Updated by Torbjorn Carlqvist Admin about 3 years ago · 10 revisions