Device
Through the api, a devices can be created, deleted and changed.
Query Device
let device
try {
device = await api.device( deviceId ).get()
} catch ( ex ) {
// error handling
}
The device
variable in the script will then have all of the device information. That information will include Metadata, ids, data and all other information associated with the device.
Other methods are:
- update( newDeviceInfo ) - patches the device with the
newDeviceInfo
- delete() - deletes the device
- history( options ) - options should include a query to make against the device history
- events() - has a list method, create and ack method
- getHistorical( options ) - makes a get request to the historical path of the device
- setValue( path, value, options ) - sets
value
on the device atpath
- startSim( options ) - starts a simulation on the device
- pauseSim( options ) - pauses a simulation on the device
- restSim( options ) - resets a simulation on the device
- playScenario( options ) - plays a scenario on the device
- stopScenario( options ) - stops a scenario on the device
- getUpdater( path ) - makes a call to get an updater
- getUpdaters( options ) - makes a call to get the updaters for a device
- verify( options )
- users() - object to interact with the system users
Creating a Device
To create a new device, the system
method of api needs to be used.
const device = { ...newDeviceInfo }
try {
api.system( systemId ).devices().create( device )
} catch ( ex ) {
// error handling
}
after this call has been resolved, there will be a new device for the system.