Code Hook Screenshot
Code Hook Methods
|Determines whether or not the device is deemed accessible. A device is GREEN in sensemetrics if it is accessible, powered and communicating, else it is RED if it is inaccessible and not communicating or not powered. Usually this code hook just powers on the device, sends a simple test command, checks the response and returns true if the response is valid, or false otherwise. A simpler implementation may just attempt to power on the device and then return true if the power is on, and false otherwise. There is also a quick Code Template power-on snippet you can use to implement this code hook.
|boolean - true if device is accessible, else false
every minute on the 15th second
|Synchronization method between cloud and Thread that is called whenever a property on the device is changed in the cloud. This can be used to alter the behavior of the device integration based on the value of properties. This method is also executed on a fixed schedule. Any property that is changed in this method is persisted permanently in both the cloud and Thread. Any property you need to show up on the Device config form page which is driven by the device itself should be set in this code hook.
- every 6 minutes on the 30th second
- whenever a property is changed on the device thru the config form
|Obtains an observation for the device and sensor. This gets called based on the desired sampling frequency that is set on the device. It can also be called immediately based on the "Trigger Now" functionality of the sensemetrics UI. The result of this code hook is usually a call to api.postObservations() to post the observations obtained from the device and/or sensor.
|User selectable sampling frequency or immediate via the sensemetrics UI
|Synchronization method between cloud and Thread that is called whenever a property on the sensor is changed in the cloud. This can be used to alter the behavior of the sensor integration based on the value of properties. This method is also executed on a fixed schedule. Any property that is changed in this method is persisted permanently in both the cloud and Thread. Any property you need to show up on the Sensor config form page which may be driven by the sensor itself should be set in this code hook.
- every 12 minutes on the 20th second
- whenever a property is changed on the sensor thru the config form
Implied objects (or magic objects) are injected into code hooks and are always available to use. Here is a summary of the implied objects that are available.
|Provides an assortment of commonly used methods to aid in development of a code hook
SIBAlgorithm Integrations API
|Provides a basic logger to aid in debugging of code hooks
|log.info("This is a log statement")
log.info("This is an info level message")
log.error("This is an error level message")
Integration Editor and API
For more info about the editor itself and its available shortcuts see SIB Integration Editor Reference.
For more info about the available Integration API methods see SIB Integration API.